Created
March 24, 2015 21:25
-
-
Save matthijsotterloo/61867f1dd710aeaef98b to your computer and use it in GitHub Desktop.
Roosterbot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
include $_SERVER['DOCUMENT_ROOT'].'../../src/whatsprot.class.php'; | |
$username = "Placeholder"; | |
$password = "Placeholder"; | |
$identity = "Placeholder"; | |
$nickname = "Placeholder"; | |
$w = new WhatsProt($username, $identity, $nickname, true); | |
$messages = array(); | |
function onGetMessage($phone, $from, $id, $type, $time, $name, $body) { | |
sendMessage($from, 'Hoi ' . $name . ', Het is niet mogelijk mij berichten te sturen.'); | |
} | |
/* function onGetGroupMessage($phone, $from, $author, $msgid, $type, $time, $name, $message) { | |
global $w; | |
$w->sendGroupsLeave($from); | |
/* global $cursewords; | |
$bad = false; | |
$words = explode(' ', $message); | |
foreach($words as $word) { | |
if(in_array(strtolower($word), $cursewords)) { | |
$bad = true; | |
} | |
} | |
if($bad == true) { | |
sendMessage($from, 'Niet schelden, ' . $name . '!'); | |
} | |
} */ | |
function sendMessage($to, $body) { | |
global $messages; | |
$message = array('to' => $to, 'body' => $body); | |
array_push($messages, $message); | |
} | |
$w->eventManager()->bind("onGetMessage", "onGetMessage"); | |
//$w->eventManager()->bind("onGroupisCreated", "onGroupisCreated"); | |
//$w->eventManager()->bind("onGetGroupMessage", "onGetGroupMessage"); | |
$w->connect(); | |
$w->loginWithPassword($password); | |
//$w->sendSetProfilePicture('../hbl.jpg'); | |
// $w->sendGetGroups(); | |
//Change group title of B2D Chat | |
$gjid = "31631185419-1372089209"; | |
//$w->sendSetGroupSubject($gjid, $subject); | |
//Print when the user goes online/offline (you need to bind a function to the event onPressence | |
//so the script knows what to do) | |
//$w->eventManager()->bind("onPresence", "onPresenceReceived"); | |
//update your profile picture | |
//$w->sendSetProfilePicture("demo/venom.jpg"); | |
//send picture | |
//$w->sendMessageImage($target, "demo/x3.jpg"); | |
//send video | |
//$w->sendMessageVideo($target, 'http://techslides.com/demos/sample-videos/small.mp4'); | |
//send Audio | |
//$w->sendMessageAudio($target, 'http://www.kozco.com/tech/piano2.wav'); | |
//send Location | |
//$w->sendLocation($target, '4.948568', '52.352957'); | |
//echo "\n\nYou can also write and send messages to $target (interactive conversation)\n\n> "; | |
$target = ($gjid); | |
//$target="31631974371"; | |
$json = json_decode(file_get_contents('http://scherm.baarnschlyceum.nl/data.php'), true); | |
$b2d = $json['changes']['classes']['today']['0']['B2d']; | |
if (empty($b2d)) { | |
$text = "Wijzigingen voor vandaag📚: \r\n \r\n Er zijn vandaag geen wijzigingen😪"; | |
echo $text; | |
} else { | |
$text = "Wijzigingen voor vandaag📚: \r\n \r\n"; | |
ksort($b2d); | |
foreach($b2d as $uur => $wijziging){ | |
$new = implode(",", $wijziging); | |
$text .= $uur.": ".$new."\r\n \r\n"; | |
} | |
// str_replace for teacher names | |
$text = str_replace(" > ",' wordt ',$text); | |
$text = str_replace(" ave ",'Averdijk ',$text); | |
$text = str_replace(" bar ",'Bauer ',$text); | |
$text = str_replace(" bax ",'Bax ',$text); | |
$text = str_replace(" bes ",'Besseling ',$text); | |
$text = str_replace(" byv ",'Bijvank ',$text); | |
$text = str_replace(" bla ",'Blaak ',$text); | |
$text = str_replace(" boe ",'Boek ',$text); | |
$text = str_replace(" bor ",'den Boer ',$text); | |
$text = str_replace(" bre ",'Boerée ',$text); | |
$text = str_replace(" bry ",'Breij ',$text); | |
$text = str_replace(" brw ",'Brouwer ',$text); | |
$text = str_replace(" bue ",'van Bueren ',$text); | |
$text = str_replace(" bun ",'van Bunnik ',$text); | |
$text = str_replace(" cus ",'Custers ',$text); | |
$text = str_replace(" dyk ",'Dijkstra ',$text); | |
$text = str_replace(" dir ",'Dirks ',$text); | |
$text = str_replace(" doo ",'Doosje ',$text); | |
$text = str_replace(" dor ",'Dorrestijn ',$text); | |
$text = str_replace(" dou ",'Doup ',$text); | |
$text = str_replace(" dri ",'Driessen ',$text); | |
$text = str_replace(" dur ",'Durmaz ',$text); | |
$text = str_replace(" elv ",'Elving ',$text); | |
$text = str_replace(" fra ",'France ',$text); | |
$text = str_replace(" fro ",'Frohn ',$text); | |
$text = str_replace(" geo ",'George ',$text); | |
$text = str_replace(" gor ",'Gordeau ',$text); | |
$text = str_replace(" har ",'van Harderwijk ',$text); | |
$text = str_replace(" hei ",'Heimensen-van der Zande ',$text); | |
$text = str_replace(" hek ",'Hekking ',$text); | |
$text = str_replace(" hse ",'van Hesse ',$text); | |
$text = str_replace(" hun ",'Huiszoon ',$text); | |
$text = str_replace(" hul ",'Hulsker ',$text); | |
$text = str_replace(" jac ",'Jacobs ',$text); | |
$text = str_replace(" jan ",'Janse ',$text); | |
$text = str_replace(" joe ",'De Jonge-Veldkamp ',$text); | |
$text = str_replace(" kar ",'Karacelik ',$text); | |
$text = str_replace(" kok ",'Kok ',$text); | |
$text = str_replace(" koy ",'Van de Kooij-Westerveld ',$text); | |
$text = str_replace(" kom ",'Koomen ',$text); | |
$text = str_replace(" laa ",'van Laanen ',$text); | |
$text = str_replace(" lan ",'Landolt ',$text); | |
$text = str_replace(" las ",'Laschewski ',$text); | |
$text = str_replace(" lef ",'Leferink ',$text); | |
$text = str_replace(" lid ",'van der Linden ',$text); | |
$text = str_replace(" lin ",'van der Linden-van de Hoef ',$text); | |
$text = str_replace(" lis ",'Lintjens ',$text); | |
$text = str_replace(" lon ",'Lonergan-van den Eshof ',$text); | |
$text = str_replace(" maa ",'Maas ',$text); | |
$text = str_replace(" mal ",'Malosse ',$text); | |
$text = str_replace(" mee ",'van der Meer ',$text); | |
$text = str_replace(" mew ",'Meeuwissen ',$text); | |
$text = str_replace(" men ",'Meeuwissen-Hauer ',$text); | |
$text = str_replace(" med ",'van der Meijde ',$text); | |
$text = str_replace(" mey ",'Meijer ',$text); | |
$text = str_replace(" mer ",'G. Meijer ',$text); | |
$text = str_replace(" mie ",'Miedema ',$text); | |
$text = str_replace(" min ",'Minet ',$text); | |
$text = str_replace(" mou ",'Mout ',$text); | |
$text = str_replace(" mre ",'Mreijen ',$text); | |
$text = str_replace(" mur ",'Mulder ',$text); | |
$text = str_replace(" nab ",'Naber ',$text); | |
$text = str_replace(" olk ",'van Oldenbeek ',$text); | |
$text = str_replace(" olt ",'Olthof ',$text); | |
$text = str_replace(" rec ",'van Ommen ',$text); | |
$text = str_replace(" ost ",'van Oost ',$text); | |
$text = str_replace(" oos ",'Oosterbaan ',$text); | |
$text = str_replace(" osk ",'Oskam ',$text); | |
$text = str_replace(" ott ",'van Otten ',$text); | |
$text = str_replace(" pee ",'Peeters ',$text); | |
$text = str_replace(" plu ",'Pluister-van Til ',$text); | |
$text = str_replace(" pol ",'Polomski ',$text); | |
$text = str_replace(" poo ",'Poortier ',$text); | |
$text = str_replace(" pop ",'Poppema ',$text); | |
$text = str_replace(" pro ",'Prouteau ',$text); | |
$text = str_replace(" pui ",'Puite ',$text); | |
$text = str_replace(" rey ",' Reijmerink ',$text); | |
$text = str_replace(" ris ",'Riemens ',$text); | |
$text = str_replace(" roy ",'Roijen-Klinckenberg ',$text); | |
$text = str_replace(" rsn ",'Rossen ',$text); | |
$text = str_replace(" rui ",'de Ruig ',$text); | |
$text = str_replace(" scs ",'Scheltus ',$text); | |
$text = str_replace(" sce ",'Schoenmakers ',$text); | |
$text = str_replace(" sct ",'Schollaardt ',$text); | |
$text = str_replace(" sch ",'Scholte ',$text); | |
$text = str_replace(" sel ",'Seleski ',$text); | |
$text = str_replace(" sic ",'Sickler ',$text); | |
$text = str_replace(" sin ",'Sinninghe Damsté ',$text); | |
$text = str_replace(" sma ",'Smedema ',$text); | |
$text = str_replace(" sme ",'Smelik ',$text); | |
$text = str_replace(" sne ",'Snel ',$text); | |
$text = str_replace(" stt ",'Stavast ',$text); | |
$text = str_replace(" sta ",'van Staveren ',$text); | |
$text = str_replace(" str ",'van der Struijk ',$text); | |
$text = str_replace(" opvang ",'Studiebegeleider ',$text); | |
$text = str_replace(" stu ",'Stuijver ',$text); | |
$text = str_replace(" tak ",'Tak ',$text); | |
$text = str_replace(" taa ",'Talamoni ',$text); | |
$text = str_replace(" tal ",'Talhaoui ',$text); | |
$text = str_replace(" the ",'W. Theulings ',$text); | |
$text = str_replace(" vag ",'Vagevuur ',$text); | |
$text = str_replace(" vee ",'van der Veen ',$text); | |
$text = str_replace(" veg ",'Veerling ',$text); | |
$text = str_replace(" ver ",'Verhoek ',$text); | |
$text = str_replace(" vem ",'Vermeule ',$text); | |
$text = str_replace(" ves ",'Verschuuren ',$text); | |
$text = str_replace(" vin ",'Vink ',$text); | |
$text = str_replace(" vis ",'Visser ',$text); | |
$text = str_replace(" vol ",'Volmer Weijland ',$text); | |
$text = str_replace(" vre ",'Vreugde ',$text); | |
$text = str_replace(" vri ",'de Vries ',$text); | |
$text = str_replace(" vrs ",'T. de Vries ',$text); | |
$text = str_replace(" wen ",'Wennink ',$text); | |
$text = str_replace(" win ",'van de Winkel ',$text); | |
$text = str_replace(" wol ",'Woltjer ',$text); | |
$text = str_replace(" wou ",'Woutman ',$text); | |
// str_replace for hours | |
// Maandag | |
$text = str_replace("ma1",'Maandag het 1de uur ',$text); | |
$text = str_replace("ma2",'Maandag het 2de uur ',$text); | |
$text = str_replace("ma3",'Maandag het 3de uur ',$text); | |
$text = str_replace("ma4",'Maandag het 4de uur ',$text); | |
$text = str_replace("ma5",'Maandag het 5de uur ',$text); | |
$text = str_replace("ma6",'Maandag het 6de uur ',$text); | |
$text = str_replace("ma7",'Maandag het 7de uur ',$text); | |
$text = str_replace("ma8",'Maandag het 8de uur ',$text); | |
$text = str_replace("ma9",'Maandag het 9de uur ',$text); | |
// Dinsdag | |
$text = str_replace("di1",'Dinsdag het 1de uur ',$text); | |
$text = str_replace("di2",'Dinsdag het 2de uur ',$text); | |
$text = str_replace("di3",'Dinsdag het 3de uur ',$text); | |
$text = str_replace("di4",'Dinsdag het 4de uur ',$text); | |
$text = str_replace("di5",'Dinsdag het 5de uur ',$text); | |
$text = str_replace("di6",'Dinsdag het 6de uur ',$text); | |
$text = str_replace("di7",'Dinsdag het 7de uur ',$text); | |
$text = str_replace("di8",'Dinsdag het 8de uur ',$text); | |
$text = str_replace("di9",'Dinsdag het 9de uur ',$text); | |
// Woensdag | |
$text = str_replace("wo1",'Woensdag het 1de uur ',$text); | |
$text = str_replace("wo2",'Woensdag het 2de uur ',$text); | |
$text = str_replace("wo3",'Woensdag het 3de uur ',$text); | |
$text = str_replace("wo4",'Woensdag het 4de uur ',$text); | |
$text = str_replace("wo5",'Woensdag het 5de uur ',$text); | |
$text = str_replace("wo6",'Woensdag het 6de uur ',$text); | |
$text = str_replace("wo7",'Woensdag het 7de uur ',$text); | |
$text = str_replace("wo8",'Woensdag het 8de uur ',$text); | |
$text = str_replace("wo9",'Woensdag het 9de uur ',$text); | |
// Donderdag | |
$text = str_replace("do1",'Donderdag het 1de uur ',$text); | |
$text = str_replace("do2",'Donderdag het 2de uur ',$text); | |
$text = str_replace("do3",'Donderdag het 3de uur ',$text); | |
$text = str_replace("do4",'Donderdag het 4de uur ',$text); | |
$text = str_replace("do5",'Donderdag het 5de uur ',$text); | |
$text = str_replace("do6",'Donderdag het 6de uur ',$text); | |
$text = str_replace("do7",'Donderdag het 7de uur ',$text); | |
$text = str_replace("do8",'Donderdag het 8de uur ',$text); | |
$text = str_replace("do9",'Donderdag het 9de uur ',$text); | |
// Vrijdag | |
$text = str_replace("vr1",'Vrijdag het 1de uur ',$text); | |
$text = str_replace("vr2",'Vrijdag het 2de uur ',$text); | |
$text = str_replace("vr3",'Vrijdag het 3de uur ',$text); | |
$text = str_replace("vr4",'Vrijdag het 4de uur ',$text); | |
$text = str_replace("vr5",'Vrijdag het 5de uur ',$text); | |
$text = str_replace("vr6",'Vrijdag het 6de uur ',$text); | |
$text = str_replace("vr7",'Vrijdag het 7de uur ',$text); | |
$text = str_replace("vr8",'Vrijdag het 8de uur ',$text); | |
$text = str_replace("vr9",'Vrijdag het 9de uur ',$text); | |
echo $text; | |
} | |
$w->sendMessage($target,$text); | |
while(true) { | |
$w->PollMessage(); | |
sleep(1); | |
foreach($messages as $key => $message) { | |
$w->sendMessage($message['to'], $message['body']); | |
unset($messages[$key]); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment