开发者

Python IRC bot with support for plugins and not command only

开发者 https://www.devze.com 2023-04-06 19:43 出处:网络
I have just made a script in Python which will connect to my MySQL database every XX second and check for new posts on my forum. If there are any new posts, I would like to have the user\'s of my IRC

I have just made a script in Python which will connect to my MySQL database every XX second and check for new posts on my forum. If there are any new posts, I would like to have the user's of my IRC channel notified. To do this I need to hook up my script with an IRC bot. I have been searching around to find an IRC bot which supports plugins which are not only called by commands (e.g. ".google example") as I would like my script to be running constantly and when new posts are found have the bot print a message.

Does anyone know of an IRC bot which开发者_C百科 would allow me to do that?


You could always take a look at Twisted, which is supposed to make it very easy for you to create your own IRC bot:

http://twistedmatrix.com/documents/10.0.0/api/twisted.words.protocols.irc.IRC.html


you should easily find a python IRC client library which would let you do (almost) anything you want directly from your python script.

the Python Package Index (aka. pypi) lists some irc client libraries...


As a kind of shameless plug, I will point to the IRC bot that I have developed with ease of extensibility in mind (via plugins and custom commands):

  • http://github.com/Xion/seejoo

While its plugins are generally meant to be driven by IRC events (such as an user joining a channel) and not a time-based "ticks", I think it would be feasible to utilize the "someone said something on channel" (message) event as a trigger for your database poll.

If you would like to play with this thing, I recommend looking at already existing plugins - especially the memo one.


I am using the Twisted Library as suggested by @Fabian. Following the guide below, you will end up having a good skeleton for an IRC but which is easily extendable with your own plugins.

http://www.eflorenzano.com/blog/post/writing-markov-chain-irc-bot-twisted-and-python/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号