Strings
Strings

Reputation: 133

How can I control my Twisted-based Python IRC bot interactively?

So I've got the beginnings of a pretty basic IRC bot, using Twisted's IRC client:

http://pastebin.com/jjMSM64n

How would I go about hooking into the bot/factory/reactor so I could control the bot via the command line?

So when the bot is ran via CLI, it starts up as usual but drops you into a wee custom interactive prompt. I think this CLI/message loop would have to be where reactor.run() is though.. and I'm not sure how that would all work.

Any suggestions?

Upvotes: 2

Views: 317

Answers (1)

t2d
t2d

Reputation: 476

I think you just want to use the twisted.internet.stdio.StandardIO.

Look at the examples:

  • stdin.py - reading a line at a time from standard input without blocking the reactor
  • stdiodemo.py - example using stdio, Deferreds, LineReceiver and twisted.web.client.

Upvotes: 1

Related Questions