【问题标题】:Python IRC bot that reads data returned from a command of the IRC serverPython IRC bot 读取从 IRC 服务器的命令返回的数据
【发布时间】:2013-01-16 19:28:26
【问题描述】:

我有一个与PHP IRC bot that reads data returned from a command of the IRC server类似的问题

我正在使用一个用 Python 编写的 IRC 机器人,该机器人在网络上很常见。

我必须向 IRC 服务器发送一个“NAMES”命令,然后它会返回一个当前在机器人所在频道中的用户名列表。但我似乎无法捕捉到该列表,NOR 从服务器获取消息 - 机器人接收并打印其他用户发送的消息,但不是他自己也不是命令输出。

要打印我正在使用的数据:

while True:
    data = irc.recv ( 4096 )
    (...)
    print data

要发送 NAMES 命令,我尝试了以下操作:

irc.send ( 'NAMES #channel\r\n' )

还有:

irc.send ( 'PRIVMSG #channel :/names\r\n' )

pastebin dot com 上的完整代码:http://pastebin.com/xjymEjPu

【问题讨论】:

标签: python bots irc names


【解决方案1】:

我刚刚在脚本输出中看到了 NAMES 列表

:botty!~botty@durrrrrrrrr JOIN :#channel
:retribution.sg.as.irchighway.net 353 botty = #channel :botty IlPalazzo-ojiisan @Nibelung 
:retribution.sg.as.irchighway.net 366 botty #channel :End of /NAMES list.
:retribution.sg.as.irchighway.net 353 botty = #channel :botty IlPalazzo-ojiisan @Nibelung 
:retribution.sg.as.irchighway.net 366 botty #channel :End of /NAMES list.

不过,这不是弹出的最后一件事。也许你错过了?它位于一组全局通知之上,它们是最后返回的行。

【讨论】:

  • :) 很容易错过。我原以为它会在底部弹出,只是在 telnet 进入时才发现它。还值得注意的是,NAMES 列表存在两次,那是因为您在加入频道时会自动收到它。
猜你喜欢
  • 2012-10-13
  • 2012-10-15
  • 1970-01-01
  • 1970-01-01
  • 2014-10-16
  • 2015-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多