Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket,base64,zlib,binascii
- SERVER = 'irc.root-me.org'
- PORT = 6667
- NICKNAME = 'new'
- CHANNEL = "#root-me_challenge"
- def login(nickname, username = 'new', password = None, realname='new', hostname = 'new', 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 : !ep4\r\n')).encode('utf-8'))
- if (message.decode('utf8')).find('PRIVMSG') != -1:
- print ('message reçu par candy : ' + message.decode('utf-8'))
- chaine = (message.decode('utf-8'))[((message.decode('utf-8'))[1:].find(":")) + 2:]
- chaine = chaine[:chaine.find("\\")]
- print("chaine à décoder : " + chaine)
- reponse = base64.b64decode(chaine)
- print("chaine a decompresser " + str(reponse))
- binascii.hexlify(reponse)
- reponse = zlib.decompress(reponse)
- print('chaine decompressee:', reponse)
- print("notre reponse : " + str(reponse))
- reponse = reponse.decode('utf-8')
- result = (('PRIVMSG Candy !ep4 -rep ' + str(reponse) + '\r\n'))
- bot.send(result.encode('utf-8'))
- print(bot.recv(8192))
- break
- bot.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement