はてなのお気に入りアンテナをTwitter Clientで見れるゲートウェイ「Hatetter」作りました ã¨åããããªãã¨ãï¼Twitterã¯ã©ã¤ã¢ã³ãã§ã¯ãªãï¼IRCã¯ã©ã¤ã¢ã³ãã§ããããã£ãã®ã§ãï¼
ã¨ããããã§ï¼Pigã¨ããã®ãæ¸ãã¦githubã«ããã¦ããã¾ãï¼
Myã¯ã¦ãªãRSS Feedã®æ°çé ç®ãçºè¨ãã¦ãããIRCdã§ãï¼ãã®ãã¡ï¼Perlã§ãã«ããã«ãããçµæãIRCdã«ãªããã©ã¤ããªæãã®ãã¬ã¼ã ã¯ã¼ã¯ã«ãªãäºå®ã§ãï¼
追è¨: Mooseã®ä¾åãã²ã©ããããã®ã§ã¨ããããAny::Mooseåããã®ã§ï¼ãããã¯å ¥ãããããªã£ã¦ã?
Myã¯ã¦ãªãã¦ã©ãã
ã¨ãããã以ä¸ã®ããã«ããã¨ï¼IRCã¯ã©ã¤ã¢ã³ãã§Myã¯ã¦ãªãã¦ã©ããã§ãã¾ãï¼
$ git clone git://github.com/hakobe/pig.git $ cd pig $ vim config/myhatena.yaml # ããªãã®hatena_idãæ´æ°ééããã£ã¦ããã¦ãï¼ $ perl -Ilib script/pig.pl config/myhatena.yaml
ãã¼ã«ã«ã®16667ãã¼ãã§IRCdãèµ·åããã®ã§ï¼ã使ãã®IRCã¯ã©ã¤ã¢ã³ãã§æ¥ç¶ãã¦ãã ããï¼
IRCã¯ã©ã¤ã¢ã³ãããç¹å®ã®ãã£ã³ãã«ã«joinããã¨ï¼Myã¯ã¦ãªã®æ°çæ å ±ããªããã¦æ¥ã¾ãï¼ãã£ã³ãã«ã«æµãã¦ããæ°çæ å ±ã®ç¨®é¡ã¯ãã£ã³ãã«ã®ååã§æ±ºã¾ãã¾ãï¼
- #antenna : ããªãã®Myã¯ã¦ãªã¢ã³ããã®æ°ç
- #{hatena_id} : id:{hatena_id} ããã®æ°ç
ããã§ï¼æ°ã«ãªããã®åãã¦ã©ãããã¾ããã§ãï¼
RSSãã¦ã©ãã
ãã¨ï¼å¯ä½ç¨çã«RSSãIRCã¯ã©ã¤ã¢ã³ããããã§ãã¯ã§ããããã«ãªã£ãã®ã§ããï¼æå¤ã¨ä¾¿å©ã§ãï¼
$ cd pig $ vim config/feed_reader.yaml $ perl -Ilib script/pig.pl config/feed_reader.yaml
feed_reader.yamlã«ã¯ï¼Feedãæµããããã£ã³ãã«ã¨Feedã®uriã®çµãæ¸ãã¦ããã¾ãï¼ãã£ã³ãã«ã«joinããã¨æå®ããFeedããªããã¦ãã¾ãï¼
port: 16668 log_level: debug service: name: FeedReader interval: 300 # 5åæ¯ã«ãã§ã㯠bot_name: feed # feedãããã¹ãbotã®åå channels: '#fse': feeds: - uri: http://www.douzemille.net/labs/urlstack/rss.cgi - uri: http://www.himitsu.net/himitsunofeed '#gmail': # Gmailã®æ°ç feeds: - uri: https://id:[email protected]/mail/feed/atom/ '#gmail-hatena': # Hatenaã©ãã«ã®ã¤ããGmailã®æ°ç feeds: - uri: https://id:[email protected]/mail/feed/atom/hatena
IRCã¯ãã£ã¨è¦ã¦ããã®ã§ï¼å¸¸ã«ãã§ãã¯ãããFeedãï¼LDRã¨ãã«ç»é²ã§ããªãèªè¨¼ä»ãã®Feedãç»é²ãã¦ããã¨ä¾¿å©ã§ãï¼
ä¸ã®è¨å®ä¾ã®ããã«Gmailã®Atom FeedãIRCã§æµãã¦ããã®ã便å©ã§ãï¼ç¹ã«ã¯ã¦ãªããæ¥ãã¡ã¼ã«ãIRCã§ã¦ã©ãããã¦ããã¨ï¼ãid:hakobe932ããã®ãã¤ã¢ãªã¼ã«ã³ã¡ã³ããä»ãã¾ãããã¿ãããªã¿ã¤ãã«ã«åå¿ãã¦IRCã¯ã©ã¤ã¢ã³ããæãã¦ãããã®ã§ï¼idã³ã¼ã«ã¨ããããã«ããã£ã¦ä¾¿å©ã§ããï¼*1
ã¾ã¨ã
ã¨ããããã§ï¼IRCã¯ã©ã¤ã¢ã³ãã§Myã¯ã¦ãªãRSSãã¦ã©ããããIRCdã§ããï¼
ã¨ãããããªãã§ãIRCã¯ã©ã¤ã¢ã³ãã§ã¿ããããã«ãã¦ããã¨ï¼ããããªãã¼ã«ãåãæ¿ããå¿ è¦ããªãã¦æ¥½ã¡ãã§ãï¼ããã«ï¼IRCå¨è¾ºã«ã¯ããããã¨ãã¼ã«ãããã£ã¦ããã®ã§ï¼å¼ã°ããã¨ãã«éç¥ãã¦ãããããï¼ãã°åããç°¡åã ã£ããï¼mobircãªã©ã使ã£ã¦ã¢ãã¤ã«ã§ããã¤ã§ãã¿ããããã¦ä½ãã¨æè»ã«å©ç¨ã§ãã¾ãï¼IRCã¨ã¦ã便å©ï¼
pigèªä½ã¯ã¾ã ããããä½æ©è½ã§å®æ度ãä½ãæãã§ããï¼IRCdã«ä¹ããããã¨ãå¢ãããã³ã«é«æ©è½ã«ãªã£ã¦ããäºå®ã§ãããã¾ãï¼ããä½ãããï¼IRCdã«ä¹ãããæ©è½ãããã°ãã²æãã¦ãã ããï¼
ãã¾ã: å®è£ ã«ã¤ãã¦
ãã¬ã¼ã ã¯ã¼ã¯ã«ãããé¨åã¯ï¼POE::Compoenent::Server::IRCãã¤ãã³ããhookããããããã«ã¡ãã£ã¨ã ãã©ããããæãã«ãªã£ã¦ãã¾ãï¼POE::Compoenent::Server::IRCã¯IRCã®ãããã³ã«ãç´°ãã調ã¹ãªãã¦ãç°¡åã«IRCdãæ¸ãã¦ä¾¿å©ã§ãï¼pigã§ã¯å ãã¦ï¼å®æçã«RSSããã§ãã¯ãã«ããã¤ãã³ããPOEä¸ã§èµ·ããã¦ï¼ãããhookã§ããããã«ãªã£ã¦ãã¾ãï¼
ããã¯ã¾ã ï¼ããããä½æ©è½ã§ï¼hookã§ããã¤ãã³ããããªãå¶éããã¦ãã*2ï¼å®æçã«ãã§ãã¯ã«ã¼ãã³ãã¾ãããããããã§ãã¾ããï¼ä»å¾ã«æå¾ ã§ãï¼ä½¿ãã¨ãã«è¿½å ãããäºå®ã§ãï¼
Myã¯ã¦ãªãRSSãèªãé¨åã¯ï¼Serviceã¨ãã種é¡ã®ã¯ã©ã¹ã«ãªã£ã¦ãã¦ï¼ä¸ã¤ã®pigãã¨ã«ä¸ã¤æ¸¡ããã¾ãï¼Serviceã¯ãã¾ã®ã¨ããï¼ãã¬ã¼ã ã¯ã¼ã¯ãã渡ãããã¤ãã³ããå¦çã§ããã°ãªãã§ãè¯ããªã£ã¦ãã¾ãï¼Serviceãæ¸ãã°ï¼ç°¡åã«IRCdã«æ©è½ãè¼ãããããã«ãªãã®ãç®æ¨ã§ãï¼
å ¨ä½çãªè¨è¨ã¯ã¾ã ãã¾ãã¡ãªæããªã®ã§ï¼ç¶ºéºã«æ½è±¡åãããã¨ããã§ãï¼ãã¾ã¯ã¡ã¤ã³ã¯ã©ã¹ã«POE::Compoenent::Server::IRCã®ã¤ãã³ãå¦çããã£ã¦ããããã®ã§ï¼ããããã¾ãåå²ãããã¨ãï¼(POEã®ã¤ãã³ããæ±ãã¨ãããè¤éã«ãªããã¡ãªãã ããªãï¼) Serviceãã¡ããã¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ããããã§ãï¼