<?php require_once 'vendor/autoload.php'; class SkypeBot { static function notify($a) { global $n; $engine = new \Inviqa\SkypeEngine($n); try { $engine->parse($a); } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; } } } $d = new Dbus(Dbus::BUS_SESSION, true); $n = $d->createProxy("com.Skype.API", "/com/Skype", "com.Skype.API"); $n->Invoke("NAME PHP"); $n->Invoke("PROTOCOL 7"); $d->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'SkypeBot'); do { $s = $d->waitLoop(1000); } while (true);
#!/usr/local/bin/php <?php include "Skype.php"; include "Bot.php"; $dbus = new Dbus(Dbus::BUS_SESSION, true); $proxy = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API'); //Connect to skype $proxy->Invoke("NAME PHP"); $proxy->Invoke('PROTOCOL 8'); Skype::$bot = new Bot($proxy); $dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Skype'); // Register message listener while (1) { $votes = Skype::$bot->getVotes(); if (isset($votes)) { foreach ($votes as $chat => $vot) { if ($vot['time'] < time() - 10 * 60) { echo "Clear: " . $chat, "\n"; Skype::$bot->clearVoting($chat); } } } $s = $dbus->waitLoop(1); }