Top

Python IRC bot


Python Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Jan 24, 2009
Last Updated  Jan 24, 2009
Tags  bot  illuminati  irc  kingskrown  python 

Description

Connects to an IRC server you specify and idles. Basically this is a frame for an IRC bot.

Grab the Code

import os
import re
import socket
 
os.fork()
 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('irc.kingskrown.com', 6667))
 
s.send('NICK %s \r\n' % 'py')
s.send('USER %s \'\' \'\' :%s\r\n' % ('svs', 'python'))
s.send('JOIN %s \r\n' % '#illuminati')
 
while 1:
   buffer = s.recv(512)
 
   if not buffer:
      break
 
   regex = re.match('(?i)^PING (:[^ ]+)$', buffer)
 
   if regex is not None:
      s.send('PONG %s\r\n' % regex.group(1))
      continue
 
s.close()

Comments

  (0)  RSS

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom