PHP ãã Tiarra ã® Socket ã使ã£ã¦çºè¨ãã
Tiarra ã£ã¦ãUnix ãã¡ã¤ã³ã½ã±ãããå©ãããã§ãããã
ã¾ãããããæ®æ®µãã IRC ã«å¸¸é§ããããã« Tiarra ã使ã£ã¦ããã®ã«ãæºå¸¯ã®ããã« mobirc å
¥ãããã¨ãããªãã¦ããTiarra ã®ã½ã±ããå©ããã°ããããããï¼ã¨æãã
ã¨ããããããããPlagger ã®ãIRCã¸ã®éç¥ã¯ãã¤ãTiarra ã®ã½ã±ããçµç±ã§ãã¦ãã¦ï¼http://search.cpan.org/~miyagawa/Plagger-0.7.17/lib/Plagger/Plugin/Notify/Tiarra.pm ã使ã£ã¦ãï¼ããã使ãã°æºå¸¯ç¨ã¯ã©ã¤ã¢ã³ãã¯ãæ®éã«ã¦ã§ããã¼ã¹ã§ã¡ãã»ã¼ã¸æ稿ããã¦ãããå©ãã ãã§OKã£ã¦ãã¨ã«ãã¦ããã°ãã¤ã³ã¿ã¼ãã§ã¼ã¹ãç°¡åã«ã§ããããªã¼ã¨ãæã£ãããªãã ããã¦ãã®ã§ããã*1
ã¾ãè¦ããã«fsockopenãã¦fwriteãã¦ãã ããªãã§ãããPlaggerã®ä¸è¿°ã®Pluginã®ã½ã¼ã¹ã¯åèã«ããã¦ããã ãã¾ããã
ï¼ã¦ãTiarraã®Socketã«é¢ãã¦ã£ã¦ã©ããã«ããã¥ã¡ã³ãããã®ããªï¼ããã¾ç±å¿ã«æ¢ãã¦ãªããã©ã±ã£ã¨æ¢ããæãè¦å½ãããããï¼
Tiarra ã®è¨å® (tiarra.conf)
ããããTiarraã®Socketã使ãã«ã¯ãtiarra.confã«ï¼ã¤è¨å®ããªãããããªããã¨ãããã¾ãã
ï¼ã¤ã¯ãã½ã±ããåã
# å¤é¨ããã°ã©ã ããTiarraãã³ã³ããã¼ã«ããçºã®UNIXãã¡ã¤ã³ã½ã±ããã®ååã # ä¾ãã°"foo"ãæå®ããå ´åãã½ã±ãã/tmp/tiarra-control/fooãä½ãããã # çç¥ãããå ´åã¯ãã®æ©è½ãç¡å¹ã¨ããã # ã¾ããéUNIXç°å¢ã§ã¯ããããUNIXãã¡ã¤ã³ã½ã±ãããå©ç¨å¯è½ã§ãªãããã # ãã®ãããªå ´åã«ããã®æ©è½ã¯ç¡å¹ã¨ãªãã control-socket-name: socketname
æ¸ãã¦ããéãã§ãããããããã¨ãTiarraã®ç¨¼åä¸ã/tmp/tiarra-control/socketname ãä½ãããã
ã§ãããä¸ã¤ã以ä¸ã®ãããã¯ã追å ã
+ System::SendMessage { }
PHP ãã使ã
ã¤ã³ã¹ãã¼ã«ã¯Opnepearããã
% sudo pear install openpear/Net_Socket_Tiarra
ã½ã¼ã¹
<?php require_once 'Net/Socket/Tiarra.php'; try { $tiarra = new Net_Socket_Tiarra('socketname'); // PRIVMSG // ãã£ã³ãã«åã¨ããã¹ãããã£ã³ãã«åã¯tiarraã®è¨å®éãã«ãé¯åãã¤ããããªã©ãã $tiarra->message('#openpear@freenode', "Hello!!"); $tiarra->noticeMessage('#openpear@freenode', "Hello!!"); } catch (Net_Socket_Tiarra_Exception $e) { echo $e->getMessage(); }
ã¡ãªã¿ã«ãTiarraã®ã½ã±ããã¯
ãããªãããã§ã¡ãã»ã¼ã¸éãã°ãkã
NOTIFY System::SendMessage TIARRACONTROL/1.0\r Sender: ããã ã¼ Notice: yes or no Channel: ãã£ã³ãã«å Charset: utf-8ã¨ã Text: ã¦ããã¨
ãã¡ãããï¿¥rï¿¥nãã§åºåãã ãã
ããã§
PHPã§ãªããããçµæãIRCã«éç¥ããã®ã¨ãã©ã¯ãã³ã«ãªã£ãã¼ã
æããã£ãããªããã¯ã©ã¤ã¢ã³ãã§ãæ¸ããããªã¼ã
ã¡ããã¡ããã
*1:ãã¼ããã·ã§ã³ã¨ãã©ããªããã ã調ã¹ã¦ãªããã©