简体   繁体   English

Irc-bot使用扭曲和定期印刷

[英]Irc-bot using twisted with periodical printing

The problem I'm having is really quite small but I've been trying to figure it out for two days and I've gotten nowhere. 我遇到的问题确实很小,但是我已经设法解决了两天,但是却一无所获。

Basically I'm building an IRC bot using twisted and yes there are many examples on the web but none of them handle what you do when you want to send messages periodically. 基本上,我正在使用Twisted构建IRC机器人,是的,网络上有很多示例,但是当您要定期发送消息时,它们都无法处理您的工作。

I want my bot to run a loop that, if a new tweet is avalible on a twitter account I follow, prints the tweet into a IRC channel. 我希望我的机器人运行一个循环,如果在我关注的Twitter帐户上有一条新推文,则将该推文打印到IRC频道中。 I've gotten the twitter part to work and the bot connects just fine but the problem occours when I try to get it to write something to the channel. 我已经完成了twitter部分的工作,并且bot连接正常,但是当我尝试使它向通道中写入内容时,问题就出现了。 It just complains. 它只是抱怨。 The code below is the closest I've come to getting it to work, but I still get the error message: TypeError: unbound method msg() must be called with IrcBot instance as first argument (got module instance instead) 下面的代码是我最近使它能够正常工作的代码,但是我仍然收到错误消息: TypeError:必须以IrcBot实例作为第一个参数调用未绑定方法msg()(而是使用模块实例)

I kind of understand what it's saying but I shouldn't have to instansiate the protocol should I? 我有点理解这是什么意思,但我不必实例化该协议吗? The code is linked below (didn't want to spam it up too hard) and if someone could give me a solution I'd be forever thankful :) 该代码链接在下面(不想把它滥发垃圾邮件),如果有人可以给我解决方案,我将永远感激:)

http://pastebin.com/HYtKRmD4 http://pastebin.com/HYtKRmD4

This is very similar to a question answered in the Twisted FAQ, http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother 这非常类似于Twisted FAQ( http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonother)中回答的问题。

Also, I think your question summary is a little confused. 另外,我认为您的问题摘要有些混乱。 You describe a scenario where you want to generate IRC output ''in response to an event''. 您描述了一种情况,其中您想“响应事件”生成IRC输出。 "Periodically" implies repetition based on timing - for example, doing something every 15 seconds. “定期”表示基于定时的重复-例如,每15秒执行一次操作。 The answer to that question is significantly different from the answer to the question you actually asked. 该问题的答案与您实际提出的问题的答案有很大不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM