Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IRC Python Bot: Best Way [closed]

Tags:

python

bots

irc

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()
like image 271
Noah Clark Avatar asked Jul 08 '09 22:07

Noah Clark


1 Answers

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?

like image 97
Unknown Avatar answered Oct 26 '22 14:10

Unknown