IRC protokoll, no such nick/channel
Verfasst: Montag 5. Mai 2014, 21:54
Hey JO, ich hab vor fast genau einem Jahr einen stümperhaften irc client/bot mit python programmiert, mit diesem code:
Den würde ich jetzt gerne wieder aktivieren um wieder ein bisschen reinzukommen(in python). Komischerweise funktioniert der code nicht mehr so wie damals :K Ich hab schon ein bisschen dran rumgeändert, hat leider nix gebracht, bei der Version jetzt(so wie sie da steht) funktioniert ping pong and Verbinden, aber irgendwo gibt es anscheinend Probleme mit dem joinen von channeln(schönes denglisch). Also am Ende kommt immer "No such nick/channel". Vielleicht kennt sich jemand damit aus und kann mir helfen?
LG
Code: Alles auswählen
import time
import socket
from contextlib import closing
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
class bot:
def main(self):
print "Socket(Client)"
host = "irc.iz-smart.net"
port = 6667
PASS = "7987fshd"
NICK = "Testikus"
USER = "Testikus localhost irc.iz-smart.net :Testikus"
self.login(PASS, NICK, USER, host, port)
print "Verbindung aufgebaut zu {0}(IP:{1})".format(
host, socket.gethostbyname(host)
)
self.schleife()
def schleife(self):
while True:
antwort = sock.recv(4096)
join = "JOIN #testblablub \r\n"
print antwort
if antwort[0:4] == "PING":
self.pong(antwort, join)
elif antwort.split()[3] != "":
self.reply()
def pong(self, antwort, join):
sock.sendall("PONG " + antwort.split()[1] + "\n")
time.sleep(2)
sock.sendall(join)
sock.sendall("PRIVMSG #testblablub hi \r\n")
def constants(self):
pass
def login(self, PASS, NICK, USER, host, port):
sock.connect((host, port))
sock.sendall("PASS "+PASS+"\n")
sock.sendall("NICK "+NICK+"\n")
sock.sendall("USER "+USER+"\n")
def reply(self):
sock.sendall("PRIVMSG #testblablub du hast was geschrieben \r\n")
ausfuehren = bot()
ausfuehren.main()
LG