IRC Python Bot: Best Way [closed]
Asked Answered
S

6

11

I want to build a bot that basically does the following:

  1. Listens to the room and interacts with users and encourages them to PM the bot.
  2. Once a user has PMed the bot engage with the client using various AI techniques.

Should I just use the IRC library or Sockets in python or do I need more of a bot framework.

What would you do?

Thanks!

Here is the code I'm currently using, however, I haven't gotten it to work.

#!/usr/bin/python 
import socket
network = 'holmes.freenet.net'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
irc.send ( 'NICK PyIRC\r\n' )
irc.send ( 'USER PyIRC PyIRC PyIRC :Python IRC\r\n' )
irc.send ( 'JOIN #pyirc\r\n' )
irc.send ( 'PRIVMSG #pyirc :Can you hear me?\r\n' )
irc.send ( 'PART #pyirc\r\n' )
irc.send ( 'QUIT\r\n' )
irc.close()
Subchaser answered 8/7, 2009 at 22:17 Comment(2)
I'm close to finishing an IRC package for Python which might be able to help you out. I'll have it available here: ircutils.evanfosmark.comMetaplasm
Awesome! Thanks! I'll keep this in mind!Subchaser
P
12

Use Twisted or Asynchat if you want to have a sane design. It is possible to just do it with sockets but why bother doing it from scratch?

Protoplasm answered 8/7, 2009 at 22:35 Comment(1)
I just checked out Twisted again and found it under the IM section. Thanks for the link. What exactly does the Asynchat help with?Subchaser
M
7

If you want to have AI techniques involved, then I suggest you look at the AIML package for Python. It is the same technology that ALICE bots are done in.

Metaplasm answered 8/7, 2009 at 22:29 Comment(1)
Thanks for the heads up on the AIML package!Subchaser
A
5

If what you want is to create the AI portion, why bother writing all the code needed for the IRC connection by yourself?

I suggest using SupyBot, and simply write your AI-code as a plugin for it. There is reasonably understandable documentation and lots of example-code to find. Also, it comes with a decent amount of plugins for all sorts of uses that might complement your AI.

Almost answered 8/2, 2010 at 20:3 Comment(0)
S
4

As I'm replying ~2 years later, I'm writing this just for Googlers :-P

Just try my 'Yet Another Useless IRC Bot' here https://github.com/julienpalard/yauib permitting you to code each feature of your bot using whatever language you want.

Sissie answered 20/3, 2011 at 13:18 Comment(0)
L
2

I made a (very crappy, and for a long time being refactored) IRC bot using irclib. The documentation is next-to-nothing, but it gets rid of making you have to do all that socket connecting and such, which is stuff I really don't want to deal with. To each his own, though.

Lyonnesse answered 9/7, 2009 at 6:13 Comment(0)
C
2

Use an existing IRC library instead of implementing the protocol yourself.

Cannonball answered 5/1, 2010 at 5:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.