Julmust
Julmust

Reputation: 86

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.

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 :)

http://pastebin.com/HYtKRmD4

Upvotes: 1

Views: 371

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48335

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.

Upvotes: 1

Related Questions