Advertisement
Guest User

Untitled

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