Python IRC client: write from scratch or write a plugin for an existing structure?

For our company, I would like to have a Python-based IRC bot that checks to see if all of our customers' websites are still up and running. More specifically: I want to list a few URLs that should be visited every, say, 15 minutes. If this fails, the URL should be verified again after 5 minutes. If retrieving the URL still does not result in an HTTP 200 status code, it must echo the failed URL in the feed so that we can examine it.

I wrote a plugin for Supybot some time ago, which basically makes some of the above a rude but effective way. If I want to extend the functionality of the current code to the above “specifications”, I need to do some basic refactoring; basically it would mean starting from scratch.

The question arises: should I write a better plugin for Supybot that meets the new requirements or do I have to go for something else? Should I start from scratch (learn by myself, implementing the appropriate RFC myself, spending more time than planned) or is there a suitable structure that processes the basic IRC materials?

+4
source share
5 answers

I voted for a brand new plugin for Supybot. To learn more;)

If you do not, try python irclib . This is (still supported) python lib for IRC.

Twisted might also be fine, but it's a little, but too much ...

+4
source

For me, this is similar to the case when your application wants to talk to the IRC, and my gut reaction will be to use Twisted, which has IRC clients. This may or may not be the right decision for you, but at least it's worth exploring.

+3
source

Finally, I decided to create Twisted for my bot. Regarding the reasons:

  • Supybot already has many features. And that may be good: just create a simple plugin, plug it in and start using the bot. The downside is that you may not like some of the features already provided. As an example: I did not like that he answered everything (Error: "foo" is not a valid command.). I am sure that it can somehow be turned off, but such little things bothered me.

  • The Python IRC client library , on the other hand, felt a little bare bones. Moreover, I had to cut the threads so that the bot checked if there were several more websites left, while remaining responsive in the channel.

  • If irclib felt too low, writing a bot from scratch would certainly be. Although I definitely wanted to learn something, I also wanted to focus on the actual functionality of the bot without worrying too much about the “basic” things (for example, I don’t necessarily want to write code to identify the bot, for example, I just have some configuration settings for storing the alias and password and handle this for me.)

Twisted has a good example of a logging bot that can be used as a starting point. In addition: in the future it should not be too difficult to write a small web server (obviously using Twisted) to display the output of the bot.

Tip. In addition to the Twisted documentation, you can also watch the October 2008 Python magazine issue for Duer Farrell's article, "A Twisted Logging Server."

Thanks to those who answered the question. You put me on the right track. :)

+2
source

Writing a simple IRC bot is not that difficult. I have a template that I use for my bots, which range from SVN bots to voting status bots to bots that check connections to specific IP addresses and change the channel theme according to the result.

I can share the source if you want, although there is nothing like creating your own :)

+1
source

irc3 is a irc client library based on asyncio and venusian https://irc3.readthedocs.org/

+1
source

All Articles