Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket,math
- SERVER = 'irc.root-me.org'
- PORT = 6667
- NICKNAME = 'victoire'
- CHANNEL = "#root-me_challenge"
- def login(nickname, username = 'victoire', password = None, realname='victoire', hostname = 'victoire', servername = SERVER):
- bot.send(('USER ' + ' '+ username + ' ' + hostname + ' ' + servername + ' ' + realname + '\r\n').encode('utf-8'))
- bot.send(('NICK ' + nickname + '\r\n').encode('utf-8'))
- bot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- bot.connect((SERVER, PORT))
- login(NICKNAME)
- bot.send(('JOIN' + CHANNEL + '\r\n').encode('utf-8'))
- while (1):
- message = bot.recv(8192)
- if (message.decode('utf-8')).find('PING') != -1:
- print ((message.decode('utf-8')) + '\r\n')
- bot.send(('PONG ' + str(message.split() [1]) + '\r\n').encode('utf-8'))
- bot.send((str('PRIVMSG Candy : !ep1\r\n')).encode('utf-8'))
- if (message.decode('utf8')).find('PRIVMSG') != -1:
- print ('message reçu par candy : ' + message.decode('utf-8'))
- nb1 = (message.decode('utf-8'))[((message.decode('utf-8'))[1:].find(":")) + 2:]
- nb1 = nb1[:nb1.find("/")]
- print("nb1 : " + str(nb1))
- nb2 = (message.decode('utf-8'))[((message.decode('utf-8')).find("/")) + 1:]
- nb2 = nb2[:nb2.find("\\")]
- print("nb2 : " + str(nb2))
- reponse = (round(math.sqrt(float(nb1)) * float(nb2), 2))
- print(reponse)
- result = (('PRIVMSG Candy !ep1 -rep ' + str(reponse) + '\r\n'))
- bot.send(result.encode('utf-8'))
- print(bot.recv(8192))
- break
Add Comment
Please, Sign In to add comment