IRC Bot
Platform: Python
Published Mar 21, 2007
Updated Dec 11, 2008
you can run it on Windows by downloading
http://www.python.org/ftp/python/2.5/python-2.5.msi install that
when you want to edit it, right click on the file and hit Edit with IDLE
if you want to run it just double click on it.
It simply makes the bot join the server in this case, irc.snm.co.nz it then joins #paul, when its join privmsg's #paul and yeah
import socket
network = 'irc.snm.co.nz'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
print irc.recv ( 4096 )
irc.send ( 'NICK botty\r\n' )
irc.send ( 'USER botty botty botty :Python IRC\r\n' )
irc.send ( 'JOIN #paul\r\n' )
irc.send ( 'PRIVMSG #Paul :Hello World.\r\n' )
while True:
data = irc.recv ( 4096 )
if data.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
if data.find ( '!botty quit' ) != -1:
irc.send ( 'PRIVMSG #paul :Fine, if you don't want me\r\n' )
irc.send ( 'QUIT\r\n' )
if data.find ( 'hi botty' ) != -1:
irc.send ( 'PRIVMSG #paul :I already said hi...\r\n' )
if data.find ( 'hello botty' ) != -1:
irc.send ( 'PRIVMSG #paul :I already said hi...\r\n' )
if data.find ( 'KICK' ) != -1:
irc.send ( 'JOIN #paul\r\n' )
if data.find ( 'cheese' ) != -1:
irc.send ( 'PRIVMSG #paul :WHERE!!!!!!\r\n' )
if data.find ( 'slaps botty' ) != -1:
irc.send ( 'PRIVMSG #paul :This is the Trout Protection Agency. Please put the Trout Down and walk away with your hands in the air.\r\n' )
print data