tweet now contains max number of people present if more than 8
parent
0fd4436138
commit
668081a828
|
@ -16,18 +16,22 @@ do
|
|||
echo "$p" > /run/peoplecounter
|
||||
if [ "$p" != "$oldp" ]
|
||||
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
|
||||
if [ "$state" = "offline" ]
|
||||
then
|
||||
state="online"
|
||||
logger $0 people counter online
|
||||
logger $(basename $0) people counter online
|
||||
fi
|
||||
else
|
||||
if [ "$state" = "online" ]
|
||||
then
|
||||
state="offline"
|
||||
logger $0 people counter offline
|
||||
logger $(basename $0) people counter offline
|
||||
fi
|
||||
fi
|
||||
sleep 10
|
||||
|
|
|
@ -15,7 +15,7 @@ $statusTag = '#statusUpdate';
|
|||
// 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
|
||||
$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');
|
||||
|
||||
|
@ -49,7 +49,19 @@ if ( $currentStatus != $previousStatus ) {
|
|||
break;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue