人工ç¡è½ã¬ã¢ã³ã¡ããbotä½ãæ¹
ãæè¿botãæµè¡ãã¿ããã§ããããªãã§ãã¨ã³ã¸ãã¢ã®å½¼æ°ã¾ã§botã§ä½ãã¡ããã¿ããã§ãï¼ç»é²ãã¦ã¿ã¾ããï¼ãã¡ãªã¿ã«ä¸è¨ã®ããã°ã®äººããããããã¨ããååã§ããç§ã¨ã¯å¥äººã§ãã
ããã ãLINEã®botã¯ãµã¼ããå¿ è¦ã§ããã©ããããªã®ã¨ãå人çã«LINEã¯ããã»ã©ä½¿ããªãã®ã§ twitter ã ã£ãããªã¢ã«ã«ããã¹ãbotãããã¨å¬ãããã§ããã¨ãããã¨ã§ãRaspberry Piã§ãããªbotãä½ã£ã¦ã¿ããã¨ã«ãã¾ãããããã£ã½ãè¨èãèªåçæãã¦ããã¤ã¼ããããå®éã«åã£ãããã¾ãã使ç¨ããæè¡ã¯ä»¥ä¸ã§ããã»ã¨ãã©ä»¥åã«ãã£ããã¨ã®çµã¿åãããªã®ã§æ¥½ãã³ãã³ã§ãã
- ãã«ã³ãé£éãç¨ããæç« çæ
- pythonã§ãã¤ã¼ã
- aquestalkpiã§ã®é³å£°åæ
ã¬ã¢ã³ã¡ããbotãã¢
ãtwitterãé³å£°åæå ±ã«ãã¸ããæãåºã¦ãã¦ããã§ããã
ã¦ã©ãºããã®éããã§ãã¯ã«æ°å§ããã¦ãåãµã¼ãã¹ã®æ å ±ãå¾ã¾ããããã¤ã¢ãã°ãåºãã¨ãã
— lemon_chan_bot (@lemon_chan_bot) 2016å¹´4æ11æ¥
ã
ãã Windowsã®æ¹ã¯ãã¹ããã¦ããã¨ãããâ¦ããã®è¶ãããã¿ã³ã®è触ãã
— lemon_chan_bot (@lemon_chan_bot) 2016å¹´4æ11æ¥
é³å£°åæ
Raspberry piã§Botã«åããã¦ã¿ã
ãå¾ã¯ä¾ã«ãã£ã¦ä½ãæ¹ã§ããçµæ§é»æ³¢ãªã®ã§æ°ã«ãªãæ¹ã ãã©ããã
ã¬ã¢ã³ã¡ããbotä½ãæ¹
ãã¼ãã¦ã§ã¢
Raspberry Pi 3ãå¨è¾ºå¨æ©ãåºæ¬ã»ããã¢ããã¯ä»¥ä¸è¨äºåç §ä¸ããããã®å¾ã¯ä¸è¨è¨äºã®ã»ããã¢ãããå®äºãã¦ããåæã§èª¬æãã¦ããã¾ãã試ãã¦ã¯ãªãã§ãããå¤åRaspberry Pi 2ã§ãåãè¦é ã§åãã¨ã¯æãã¾ãã
ã¢ã¯ãã£ãã¹ãã¼ã«ãå®ãã¦è¯ãã§ãããã«ã³ãé£éãç¨ããæç« çæ
ã以åãã£ãã®ã§ä»¥ä¸ã®è¨äºãåèã«ã»ããã¢ããã
ãRaspberry Piã ã¨MeCabã¨ããã©ã¤ãã©ãªããªãã¨ã¨ã©ã¼ãåºãã®ã§ãåèãªã³ã¯ï¼æ¬è¨äºã®æå¾ã«ããã¾ãï¼ããããè²ã 調ã¹ã¾ãããä»ãªãRaspbian Jessieãå ¥ãã¦ããã°ã以ä¸ã§å¿ è¦ãªã©ã¤ãã©ãªã¯ã¤ã³ã¹ãã¼ã«ã§ãã¾ããã
$ sudo apt-get install update $ sudo apt-get install mecab $ sudo apt-get install libmecab-dev $ sudo apt-get install mecab-ipadic-utf8 $ sudo apt-get install python-mecab
pythonã§ãã¤ã¼ã
ã以åã¯èªä½ãããããããã¤ã¼ããããã¨ãã¨ãã以ä¸ã®twã使ã£ã¦ãã¾ããã
ããã®åãã·ã³ãã«ã«ã¿ã¼ããã«ããåããã®ã§é常ã«æ°ã«å ¥ã£ã¦ããã®ã§ãããpythonããã¤ã¶ããã¨ãã¡ãã¡ã·ã¹ãã ã³ã¼ã«ããªãã¨ãããªãã®ã§ãpythonããæ軽ã«åããtwythonã¨ããã©ã¤ãã©ãªã使ã£ã¦ã¿ããã¨ã«ãã¾ããã
ãã¾ãã¯ã以ä¸ã³ãã³ãã§twythonãã¤ã³ã¹ãã¼ã«
$ sudo pip install twython
ããå¾ã¯ã以ä¸ãµã¤ãã§twitterã¢ããªãç»é²ãã¦ãConsumer keyã¨Access tokenãã²ãããã¾ããããæºå¸¯é»è©±çªå·ãç»é²ããªãã¨ãããªãã®ãã¡ãã£ã¨ãã¼ãã«é«ãã§ããã https://apps.twitter.com
ããã¾ãããã°ãåèãµã¤ãã®ä¾ã«ãããããªã以ä¸ã®ãããªç°¡åãªãµã³ãã«ããã°ã©ã ã§ãã¤ã¼ãå¯è½
# -*- coding: utf-8 -*- import twython if __name__ == '__main__': consumerKey = 'CONSUMERKEY' consumerSecret = 'CONSUMERSECRET' accessToken = 'ACCESSTOKEN' accessSecret = 'ACCESSSECRET' api = twython.Twython(app_key=consumerKey, app_secret=consumerSecret, oauth_token=accessToken, oauth_token_secret=accessSecret) test_tweet_str = u'ãã¹ããã¹ã' try: api.update_status(status=test_tweet_str) except twython.TwythonError as e: print e
aquestalkpiã§ã®é³å£°åæ
ã以ä¸ã®è¨äºã®é³å£°åæã®ç®æãåèã«å®è£
ããã¼ã ãã£ã¬ã¯ããª(/home/pi/
)以ä¸ã«aquestalkpiãã£ã¬ã¯ããªãé
ç½®ããã以ä¸ã®ã³ãã³ãã§é³å£°åºåã§ãããæ¥ç¶ãã¦ããUSBããã¤ã¹çç°å¢ã«ãã£ã¦ã¯é³ãåºãªãå ´åãããã®ã§ãä¸è¨è¨äºçåèã«ãã¦è¨å®ãã¦ãã ããã
$ ~/aquestalkpi/AquesTalkPi -f ãã¹ã | aplay
人工ç¡è½ã¬ã¢ã³ã¡ããbot
ãããã¾ã§ã®æè¡ã®çµã¿åããã§äººå·¥ç¡è½ã¬ã¢ã³ã¡ããbotãã¤ããã¾ãããã½ã¼ã¹ã³ã¼ããã»ããã¢ããæ¹æ³çãã¾ã¨ãã¦GitHubã§å ¬éãã¾ããã
ãæ¸ãã¦ããéãã«ããã°ããã¢ã®ãããªãã¨ãã§ãã¾ãï¼éãè¯ããã°ï¼ãããèå³ããã°è©¦ãã¦ã¿ã¦ä¸ããã
ã¾ã¨ã
ãã¨ããããä½ã£ã¦ãã¾ã£ããã©ãã©ããããããªãããã¡ãªã¿ã«Raspberry Pi 3 ã®ã¢ããã°ãªã¼ãã£ãªã決ãã¦è¯ãé³è³ªã§ã¯ãªãã®ã§ãããRaspberry Pi 2ã«æ¯ã¹ãã¨å¿ãªãããã¤ãºãæ¹åãã¦ããæ°ãããã®ã ãã©æ°ã®ãããããï¼
åèãªã³ã¯
Raspberry Piã§MeCabã¤ã³ã¹ãã¼ã«
http://qiita.com/JO3QMA/items/6ab7ac46279b7c8f6378
Debian に MaCab と mecab-python をインストールする – ymyzk’s blog
twython
http://okuzawats.com/twitter-bot-20141010
Twitter APIを使ってRaspberry PiにCPU温度と現在時刻を呟かせる - ysdyt.net for tech memo