0
用于抽搐聊天
我想搜索IRC聊天中的某条消息。我目前的代码存在的问题是,消息实际上是一种状态,我不知道如何检测状态。Python IRC查找状态消息
代码:
while True:
try:
data = data+con.recv(1024)
data_split = re.split(r"[~\r\n]+", data)
data = data_split.pop()
for line in data_split:
print(line)
line = str.rstrip(line)
line = str.split(line)
if len(line) >= 1:
if line[0] == 'PING':
send_pong(con, line[1])
if line[1] == 'PRIVMSG':
sender = get_sender(line[0])
message = get_message(line)
channel = line[2]
print(sender + ": " + message)
if (re.match(':jtv MODE \w* +o \w*', message)):
mods.append(channel)
mods[channel].append(msg[4])
原来的状态看起来是这样的:
:JTV MODE #CHAN + O/-o #nick
我也想用MODS的阵列中的另一个文件(如果可能的话)来检查它们是否是mod。否则,我可以将它写入一个.txt文件。
请提供更多代码。而'\ w *'与IRC缺口匹配是错误的。 (仅匹配'[a-zA-Z0-9_]',没有在nick中看到^^ – 2015-04-05 05:52:39
Twitch似乎阻止用户名中的任何特殊字符。 (据我所见),你还需要什么代码? – Lynn 2015-04-05 05:54:03
我宁愿寻找由空格/空格隔开的所有东西 – 2015-04-05 06:04:15