Guest User

Untitled

a guest
Dec 7th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import socket
  2.  
  3. class Bot:
  4.     def __init__(self):
  5. self.NICK = "@@@"
  6. self.USER = "@@@"
  7. self.PASS = "@@@"
  8. self.HOST = "irc.freenode.net'
  9. self.PORT = 6667
  10. self.IN_CHANNEL = false
  11. self.CHANNEL    = '##hairybot'
  12.  
  13. def connect(self)
  14. self.s = socket.socket()
  15. self.s.connect( (self.HOST, self.PORT))
  16.  
  17. def identify(self)
  18. s.sendall('USER %s %s server :%s' % self.NICK,self.HOST,self.NICK)
  19. s.sendall('NICK %s\n' % self.NICK)
  20. s.sendall('MSG NickServ :IDENTIFY @@@ %s\n' % self.PASS)
  21.  
  22.  
  23. def join(self):
  24. while not self.IN_CHANNEL:
  25.     line = self.s.recv(500);
  26.     if "Welcome to the freenode Internet Relay Chat Network" in line;
  27.         self.s.sendall('JOIN %s\n' % self.CHANNEL);
  28.         self.IN_CHANNEL = True
  29. while true:
  30.     line = s.recv(500)
  31.     if 'PING' in line;
  32.         line = line.rstrip()
  33.         line = line.split()
  34.         self.s.send('PONG %s\n' % line[1])
  35.        
  36. def main():
  37.     bot = Bot()
  38.     bot.connect()
  39.     bot.identify()
  40.     bot.join()
  41.     bot.loop()
  42.  
  43. if __name__ == "__main__":
  44.     main()
Add Comment
Please, Sign In to add comment