Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. import socket, string
  2.  
  3. SERVER = 'irc.root-me.org'
  4. PORT = 6667
  5. NICKNAME = 'victoire'
  6. CHANNEL = "#root-me_challenge"
  7.  
  8. rot13 = str.maketrans(
  9. "ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz" ,
  10. "NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm" )
  11.  
  12.  
  13.  
  14. def login(nickname, username = 'victoire', password = None, realname='victoire', hostname = 'victoire', servername = SERVER):
  15. bot.send(('USER ' + ' '+ username + ' ' + hostname + ' ' + servername + ' ' + realname + '\r\n').encode('utf-8'))
  16. bot.send(('NICK ' + nickname + '\r\n').encode('utf-8'))
  17.  
  18. bot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  19. bot.connect((SERVER, PORT))
  20.  
  21. login(NICKNAME)
  22. bot.send(('JOIN' + CHANNEL + '\r\n').encode('utf-8'))
  23.  
  24.  
  25.  
  26. while (1):
  27.  
  28. message = bot.recv(8192)
  29.  
  30. if (message.decode('utf-8')).find('PING') != -1:
  31. print ((message.decode('utf-8')) + '\r\n')
  32. bot.send(('PONG ' + str(message.split() [1]) + '\r\n').encode('utf-8'))
  33.  
  34. bot.send((str('PRIVMSG Candy : !ep3\r\n')).encode('utf-8'))
  35.  
  36. if (message.decode('utf8')).find('PRIVMSG') != -1:
  37. print ('message reçu par candy : ' + message.decode('utf-8'))
  38.  
  39.  
  40. chaine = (message.decode('utf-8'))[((message.decode('utf-8'))[1:].find(":")) + 2:]
  41. chaine = chaine[:chaine.find("\\")]
  42.  
  43. print("chaine à décoder : " + chaine)
  44.  
  45.  
  46.  
  47. reponse = str.translate(chaine,rot13)
  48. print("notre reponse " + str(reponse))
  49.  
  50. result = (('PRIVMSG Candy !ep3 -rep ' + str(reponse) + '\r\n'))
  51. bot.send(result.encode('utf-8'))
  52. print(bot.recv(8192))
  53.  
  54. break
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. bot.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement