ingx24

Untitled

Sep 7th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import sys
  2. import socket
  3. import string
  4. import os
  5.  
  6. class Bot:
  7.     def __init__(self, host, nick, ident, realname, owner, channelinit):
  8.         self.host = host  #The server
  9.         self.nick = nick  #Bot's nick
  10.         self.ident = ident  #Identity
  11.         self.realname = realname  #Real name
  12.         self.owner = owner  #Bot owner's nick
  13.         self.channelinit = channelinit  #The channel you connect to
  14.         self.port = 6667  #The port is usually 6667
  15.        
  16.     def connect_and_listen():
  17.         s=socket.socket() #Create the socket
  18.         s.connect((self.host, self.port)) #Connect to server
  19.         s.send('NICK '+self.nick+'n') #Send the nick to server
  20.         s.send('USER '+self.ident+' '+self.host+' bla :'+self.realname+'n') #Identify to server
  21.         self.chat
  22.        
  23.     def chat():
  24.         while True:
  25.             line=s.recv(500) #recieve server messages
  26.             print line #server message is output
  27.            
  28.            
  29. gir = Bot("irc.boredicons.com", "GIR", "GIR", "GIR", "ingx24", "#stew")
  30. gir.connect_and_listen()
Advertisement
Add Comment
Please, Sign In to add comment