Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- class Bot:
- def __init__(self):
- self.NICK = "@@@"
- self.USER = "@@@"
- self.PASS = "@@@"
- self.HOST = "irc.freenode.net'
- self.PORT = 6667
- self.IN_CHANNEL = false
- self.CHANNEL = '##hairybot'
- def connect(self)
- self.s = socket.socket()
- self.s.connect( (self.HOST, self.PORT))
- def identify(self)
- s.sendall('USER %s %s server :%s' % self.NICK,self.HOST,self.NICK)
- s.sendall('NICK %s\n' % self.NICK)
- s.sendall('MSG NickServ :IDENTIFY @@@ %s\n' % self.PASS)
- def join(self):
- while not self.IN_CHANNEL:
- line = self.s.recv(500);
- if "Welcome to the freenode Internet Relay Chat Network" in line;
- self.s.sendall('JOIN %s\n' % self.CHANNEL);
- self.IN_CHANNEL = True
- while true:
- line = s.recv(500)
- if 'PING' in line;
- line = line.rstrip()
- line = line.split()
- self.s.send('PONG %s\n' % line[1])
- def main():
- bot = Bot()
- bot.connect()
- bot.identify()
- bot.join()
- bot.loop()
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment