Irc-bot使用twisted与期刊打印
我遇到的问题确实很小,但我已经尝试解决了两天,但毫无进展。
基本上我正在使用twisted构建一个IRC机器人,是的,网络上有很多例子,但是当你想要定期发送消息时,它们都不能处理你所做的事情。
我希望我的机器人运行一个循环,如果我关注的 Twitter 帐户上有新推文,则将该推文打印到 IRC 频道中。我已经让 Twitter 部分正常工作,并且机器人连接得很好,但是当我尝试让它向频道写入内容时,问题就出现了。它只是抱怨。下面的代码是我最接近让它工作的代码,但我仍然收到错误消息: 类型错误:必须使用 IrcBot 实例作为第一个参数调用未绑定方法 msg()(改为获取模块实例)
我有点明白它在说什么,但我不应该实例化协议,不是吗?代码链接如下(不想太难地发送垃圾邮件),如果有人能给我一个解决方案,我将永远感激不已:)
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.
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. 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. 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)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与 Twisted 常见问题解答中回答的问题非常相似,http://twistedmatrix.com/trac/ wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother
另外,我认为你的问题摘要有点混乱。您描述了一个场景,您希望生成“响应事件”的 IRC 输出。 “定期”意味着根据时间进行重复 - 例如,每 15 秒做某事。该问题的答案与您的问题的答案显着不同实际上问了。
This is very similar to a question answered in the Twisted FAQ, http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother
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''. "Periodically" implies repetition based on timing - for example, doing something every 15 seconds. The answer to that question is significantly different from the answer to the question you actually asked.