我正在使用此模板尝试转发提及某个标签的帖子。在这种情况下,#pleaseletthisbe
。
当用户在推文中提到Bot时,Bot将转发推文。但是,当用户推特其中一个Hashtags时,没有发布任何内容。
我使用PyBot和magicschoolbot.py作为参考。原始文件中的一些代码已被注释掉。
from pybot import PyBot
import re
class MagicSchoolBot(PyBot):
def bot_init(self):
self.config['api_key'] = 'XXXX'
self.config['api_secret'] = 'XXXX'
self.config['access_key'] = 'XXXX'
self.config['access_secret'] = 'XXXX'
self.config['tweet_interval'] = 6 * 60
self.config['search_interval'] = 2 * 60
self.config['search_keywords'] = [
'"#Pleaseletthisbe"',
'"#pleaseletthisbe"',
'"#PleaseLetThisBe"',
'"#PLEASELETTHISBE"',
]
def on_tweet(self):
pass
def on_mention(self, tweet, prefix):
self.api.retweet(tweet.id)
def on_timeline(self, tweet, prefix):
pass
def on_search(self, tweet):
## name = tweet.user.screen_name
## status = "@" + name + " with the Frizz? No way!"
## self.update_status(status, reply_to = tweet)
match = re.search('', tweet.text)
self.api.retweet(tweet.id)
def on_follow(self, friend):
pass
if __name__ == "__main__":
bot = MagicSchoolBot()
bot.run()