tweet now contains max number of people present if more than 8

master
Level2 Pidor 2016-01-28 23:25:31 +01:00
parent 0fd4436138
commit 668081a828
2 changed files with 21 additions and 5 deletions

View File

@ -16,18 +16,22 @@ do
echo "$p" > /run/peoplecounter echo "$p" > /run/peoplecounter
if [ "$p" != "$oldp" ] if [ "$p" != "$oldp" ]
then then
logger $0 changed from $oldp to $p people logger $(basename $0) changed from $oldp to $p people
if [ "$p" -gt "$oldp" ]
then
echo "$p" > /run/peoplecountermax
fi
fi fi
if [ "$state" = "offline" ] if [ "$state" = "offline" ]
then then
state="online" state="online"
logger $0 people counter online logger $(basename $0) people counter online
fi fi
else else
if [ "$state" = "online" ] if [ "$state" = "online" ]
then then
state="offline" state="offline"
logger $0 people counter offline logger $(basename $0) people counter offline
fi fi
fi fi
sleep 10 sleep 10

View File

@ -15,7 +15,7 @@ $statusTag = '#statusUpdate';
// Set the messages to tweet when the status of the hackspace changes // Set the messages to tweet when the status of the hackspace changes
// %s is going to be replaced by the current time to avoid duplicate tweets on Twitter // %s is going to be replaced by the current time to avoid duplicate tweets on Twitter
$messageOpen = "It's %s and we are open \o/ \ncome in and create something awesome =) \nhttps://Level2.lu/openingTimes"; $messageOpen = "It's %s and we are open \o/ \ncome in and create something awesome =) \nhttps://Level2.lu/openingTimes";
$messageClosed = "We just closed our doors at %s \nSee you very soon... \nhttps://Level2.lu/openingTimes"; $messageClosed = "We just closed our doors at %s \n%sSee you very soon... \nhttps://Level2.lu/openingTimes";
require_once('TwitterAPIExchange.php'); require_once('TwitterAPIExchange.php');
@ -49,7 +49,19 @@ if ( $currentStatus != $previousStatus ) {
break; break;
case 'closed': case 'closed':
$status = sprintf( $messageClosed, date( 'H:i' ) ); $peopleMax="";
if($peopleMax=file_get_contents("/var/run/peoplecountermax")) {
$peopleMax=str_replace("\n", '', $peopleMax);
file_put_contents("/var/run/peoplecountermax","0");
if($peopleMax>8) { // only write this info if the place has been quite busy
$peopleMax="There were up to $peopleMax hackers today.\n";
} else {
$peopleMax="";
}
} else {
$peopleMax="";
}
$status = sprintf( $messageClosed, date( 'H:i' ), $peopleMax );
break; break;
} }