0
我想这个例子作为一个起点,使IRC客户试图在python IRC例如,客户端不可见的聊天
import sys
import socket
import string
HOST="irc.debian.org"
PORT=6667
NICK="_MauBot"
IDENT="_maubot"
REALNAME="_MauritsBot"
readbuffer=""
s=socket.socket()
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
while 1:
readbuffer=readbuffer+s.recv(1024)
temp=string.split(readbuffer, "\n")
readbuffer=temp.pop()
for line in temp:
line=string.rstrip(line)
line=string.split(line)
if(line[0]=="PING"):
s.send("PONG %s\r\n" % line[1])
我也使用Xchat
程序连接到irc.debian.org
。问题是,我看不到_maubot
作为聊天中的用户,我也没有看到名字连接或断开连接的人。为了创建这样一个应用程序,我需要一些方法来测试它,但必须有一些做错的事情。有任何想法吗?
你是什么意思的“看......作为聊天中的用户”?你没有加入频道(尝试发送'JOIN#频道\ r \ n'),所以无处可见.. – Phillip 2014-10-04 10:17:50
我认为有一些irc.debian.org的默认频道,它应该是#debian。但即使我加入使用s.send(“JOIN #acal \ r \ n”),如果我加入同一个频道,我不会在Xchat中看到我自己。 – Dracke 2014-10-04 10:31:12
不,该服务器上没有默认通道。如果'JOIN'不起作用,那么你正在做其他的事。尝试打印服务器的响应。它是可读的明文,并应包含错误消息。我怀疑你的昵称/用户组合是无效的。 – Phillip 2014-10-04 15:46:35