Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding=utf-8 -*-
- '''
- 「むくり」と「ぱたり」に反応するBOT
- '''
- import twitter
- import re
- from time import sleep
- # 初期値定義
- since = 0
- mukuri = re.compile(u"むくり")
- patari = re.compile(u"ぱたり")
- # twitter ログイン
- api = twitter.Api(username='twitter username', password='twitter password')
- while 1: # 無限ループ
- # TL取得
- tl = api.GetFriendsTimeline(since_id=since)
- for tweet in tl:
- since = tweet.id
- if mukuri.search(tweet.text) is not None:
- text = "@" + tweet.user.screen_name + " おはよう"
- api.PostUpdate(text.decode('utf-8'), in_reply_to_status_id=tweet.id)
- if patari.search(tweet.text) is not None:
- text = "@" + tweet.user.screen_name + " おやすみ"
- api.PostUpdate(text.decode('utf-8'), in_reply_to_status_id=tweet.id)
- sleep(60*5) # 5分おきに実行
Add Comment
Please, Sign In to add comment