sudo apt-get install php5-dev
sudo apt-get install php-pear pear install PEAR
sudo apt-get install libdbus-1-dev libxml2-dev pecl install dbus-beta
echo -e "; configuration for php DBus module\nextension=dbus.so"| sudo tee -a /etc/php5/conf.d/dbus.ini
dbus Dbus support => enabled Version => 0.1.0
$dbus = new Dbus(Dbus::BUS_SESSION, true); // Dbus $n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API'); // $n -> Invoke('NAME PHP'); // , $n -> Invoke('PROTOCOL 8'); //
// class phpSkype { public static function notify ($notify) { echo $notify."\n"; } } $dbus -> registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'phpSkype'); // while(1) { $s = $dbus -> waitLoop(1); }
CONNSTATUS ONLINE CURRENTUSERHANDLE *my_user* USERSTATUS DND CHATMESSAGE 5150665 STATUS READ CHATMESSAGE 5149961 STATUS READ CHATMESSAGE 5149993 STATUS READ CHATMESSAGE 5150025 STATUS READ CHATMESSAGE 5150057 STATUS READ CHATMESSAGE 5150697 STATUS SENDING CHAT #zaidin16/$e00fc2f75170ec9e ACTIVITY_TIMESTAMP 1345401315 CHATMESSAGE 5150697 STATUS SENT
<?php $dbus = new Dbus(Dbus::BUS_SESSION, true); // Dbus $n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API'); // $n -> Invoke('NAME PHP'); // , $n -> Invoke('PROTOCOL 8'); // class phpSkype { /* * . * , , * preg_match('/RECEIVED/', $notify) */ public static function notify ($notify) { if (preg_match('#RECEIVED|SENT#Uis', $notify)) { $message_id = explode(' ', $notify); bot::get_details($message_id[1]); // } } } class bot { private static $last_id; public static function get_details ($message_id) { global $n; $ch = $n -> Invoke('GET CHATMESSAGE '.$message_id.' CHATNAME'); // id , $mess = $n -> Invoke('GET CHATMESSAGE '.$message_id.' BODY'); // $aut = $n -> Invoke('GET CHATMESSAGE '.$message_id.' FROM_DISPNAME'); // /* * , , . * : , id . */ $author = explode('FROM_DISPNAME ', $aut); $chat = explode('CHATNAME ', $ch); $message = explode('BODY ', $mess); echo $author[1].': '.$message[1]."\n"; // /* * , , - * "!". */ if ($message[1][0] == '!') { self::reply($chat[1], $message[1], $message_id); } } public function reply ($chat, $message, $id) { global $n; /* * , id , , , * "!test" , * , . - id * , , id , . */ self::$last_id = $message; if (self::$last_id <= $message) { switch ($message) { case '!test': $reply = 'It\'s work!'; break; case '!help': $reply = ', '; break; default: $reply = ' !help'; break; } if ($reply != '') $n -> Invoke('CHATMESSAGE '.$chat.' '.$reply); // } else { echo ' !'."\n"; } } } $dbus -> registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'phpSkype'); // while(1) { $s = $dbus -> waitLoop(1); } ?>
Source: https://habr.com/ru/post/149850/
All Articles