Se connecter à un bot IRC en python
Bonjour, je cherche à me connecter à un bot IRC (que je n'ai pas créer) grace à python, mais j'e n'y arrive pas et mes input ne sont pas pris en compte car la console apparit puis disparait directement (je code sous notepad++). Voila ce que je fais
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| import socket, sys, math
server = "irc.root-me.org" #settings
channel = "#root-me_challenge"
botnick = "cara bruuh"
input('wait1')
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
input('wait2')
print "connecting to:"+server
input('wait3')
irc.connect((server, 6667))
input('wait4') #connects to the server
irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n") #user authentication
input('wait5')
irc.send("NICK "+ botnick +"\n") #sets nick
input('wait6')
irc.send("JOIN "+ channel +"\n") #join the chan
irc.send("PRIVMSG candy !ep1\r\n") #auth
while 1:#puts it in a loop
text=irc.recv(2040) #receive the text
print text #print text to console
if text.find('PING') != -1: #check if 'PING' is found
irc.send('PONG ' + text.split() [1] + '\r\n') #returnes 'PONG' back to the server (prevents pinging out!)"
nb1,nb2 = text.split('/')
retour = returnCollege(nb1,nb2)
irc.send('PRIVMSG Candy !ep1 -rep '+retour+'\r\n') |
De plus je ne sais pas si le JOIN est a la bonne place et a quoi sert le ping ? J'ai cherché pas mal de temps sur internet mais je n'ai pas trop compris comment un bot marche...
Cordialement.
Merci