Guest User

Untitled

a guest
Jan 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import socket,math
  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. while (1):
  20.  
  21. message = bot.recv(8192)
  22.  
  23. if (message.decode('utf-8')).find('PING') != -1:
  24. print ((message.decode('utf-8')) + '\r\n')
  25. bot.send(('PONG ' + str(message.split() [1]) + '\r\n').encode('utf-8'))
  26.  
  27. bot.send((str('PRIVMSG Candy : !ep1\r\n')).encode('utf-8'))
  28.  
  29. if (message.decode('utf8')).find('PRIVMSG') != -1:
  30. print ('message reçu par candy : ' + message.decode('utf-8'))
  31.  
  32. nb1 = (message.decode('utf-8'))[((message.decode('utf-8'))[1:].find(":")) + 2:]
  33. nb1 = nb1[:nb1.find("/")]
  34.  
  35. print("nb1 : " + str(nb1))
  36.  
  37. nb2 = (message.decode('utf-8'))[((message.decode('utf-8')).find("/")) + 1:]
  38. nb2 = nb2[:nb2.find("\\")]
  39.  
  40. print("nb2 : " + str(nb2))
  41.  
  42. reponse = (round(math.sqrt(float(nb1)) * float(nb2), 2))
  43. print(reponse)
  44.  
  45. result = (('PRIVMSG Candy !ep1 -rep ' + str(reponse) + '\r\n'))
  46. bot.send(result.encode('utf-8'))
  47. print(bot.recv(8192))
  48.  
  49. break
Add Comment
Please, Sign In to add comment