一个通过鸡蛋扩展的twitter机器人
mrpump的Python项目详细描述
Pump先生是个Twitter机器人,用的是Tweepy。
使用
安装MR泵。
在twitter上为pump先生建立一个帐户。
听泵的话,让他听你的。
访问dev.twitter.com。以泵用户身份登录。创建新的“应用程序”。
记住,只有你对你如何使用或滥用Twitter负责。
获取应用程序的开发人员访问令牌。
写一个配置文件;我们称之为golem.ini。(见下文。)
运行MR泵:
emet golem.ini
向Pump先生发送一条直接消息,例如“19 ping”。
收到他的回复:“927 Pong.”
信息中的数字是多少?
只是为了避开Twitter的“哇哦,你已经说过了!“消息。它 似乎是为了防止重复发布。但是当你和 你可能需要更多地重复你自己的电脑,而不是与人。
配置文件
[app] # OAuth info needed to log in. You get these two when you register your app - key = ABCDEFGHijkl012345MNO secret = gr0igh24g8h240gh2rvun92rnuEIIH847fhier00 # (this is the screen name of the bot) [mygolem] # - and you get these two when you get your developer access token. token = 284729478-KANEFIIGRVKNRVO3883474KFKEVDKknvdvdkn993 secret = prgiIRGJIGkvmvvnkfkKNKRFNKFIFEIV48347fenef # A name for the instance of the ping chem - [ping] # For the ping chem, use the 'ping' entry point from the 'mrpump' egg. use = egg:mrpump#ping # A name for the instance of the time chem - [time] # For this one use the 'time' entry point from the 'time_chem' egg use = egg:time_chem#time # Any additional config required by this chem format = Year %Y month %m day %d [global] # A colon-separated list of directories wherein eggs containing chems are to be # found. plugin path = /home/me/mrpump-plugins # This is the same as the section name above. screen name = mygolem # Name of a file that Mr. Pump can write in. Gets no larger than 10k. cache = /tmp/already_seen # How many seconds between checking messages. Don't make Twitter angry. check every = 60 # debug, info, error: minimum level of messages to display. Debug is quite # verbose. log level = info # Names of each section above that configures a chem. chems = ping, time
让泵先生做些很酷的事情
写一个化学物,放在鸡蛋里。然后更改配置以包括 然后重启泵先生。普雷斯托,你的新功能已经准备好了!
在examples目录中有一个time-chem。要想成功,就去做吧 目录,然后运行python setup.py bdist_egg。把鸡蛋锉 (dist/*egg)位于配置的plugin path目录中。这个 ^上面示例配置中的{tt4}$部分将加载时间模式。 现在运行emet,并dm您的bot,time。