python - 为什么我的 Python ircbot 停在 NOTICE * :*** Looking up your hostname. .. 并且不会加入 channel ?

标签 python irc bots

我的 irc 机器人卡在:calvino.freenode.net“注意 * :* 正在查找您的主机名...”在我向代码中添加一些功能之前它就可以工作了。我已经将这些功能注释掉了,但它仍然不起作用! 它停留在该消息上,没有进展。我必须强制它退出。

我是一个非常新手的编码员,大约两周前我才开始编码。所以我完全有可能在某个地方犯了一个非常愚蠢的错误。 作为引用,我使用这篇文章编写了我的机器人的框架。 http://ubuntuforums.org/showpost.php?p=9363159&postcount=3 我没有发布其余的代码,但我已将其放入此粘贴箱中,以备需要时使用! http://pastebin.com/kVF04UFr

    import socket
    import urllib2
    import httplib
    import mechanize

    channel = '#testbot'
    botnick = 'tastybot'
    network = 'irc.freenode.net'
    port = 6667
    irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
    irc.connect ( ( network, port ) )
    print irc.recv ( 4096 )
    irc.send ( 'NICK' + botnick + ':\r\n' )
    irc.send ( 'USER tastybot tastybot tastybot :Python IRC\r\n' )
    irc.send ( 'JOIN' + channel + ':\r\n' )
    irc.send ( 'PRIVMSG' + channel + ':What\'s up?\r\n' )
    running = True

    [various functions]

    while running:
        [rest of code]

最佳答案

我的猜测是,您要连接的 IRC 服务器需要提供一个 ident:

Ident is an old protocol that servers used to identify which user on a shared system was connecting to them. Nowadays, it is most often used to weed out clones and floodbots from compromised machines (which usually don't have identd [the ident daemon] installed).

来源:http://help.undernet.org/faq.php#19

最简单的解决方法是尝试连接到另一个 IRC 服务器,您可以尝试使用“holmes.freenode.net”作为您的服务器。我在该服务器上使用 IRC 机器人没有遇到任何问题。

编辑: 如果您想查看我用于连接服务器的代码:connection.py

关于python - 为什么我的 Python ircbot 停在 NOTICE * :*** Looking up your hostname. .. 并且不会加入 channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9551409/

相关文章:

python - Django 模板表达式中的 "bar"是文字吗?

python - OpenAI gym mujoco ImportError : No module named 'mujoco_py.mjlib'

python - pyOpt for python 3安装报错

python - 将一个 Twisted 工厂接收到的数据发送到第二个工厂

python - Willie python irc bot - 获取 channel 上的昵称列表

bots - Bot 框架模拟器错误 : POST 500 directline postActivity

python - Tweepy - 排除转推

irc - 有没有办法在不加入 IRC channel 的情况下获得用户?

javascript - 使用 Mozilla 框架编写非 GUI 机器人

botframework - 无法通过 Azure 门户创建 Web 应用程序机器人,出现 ServiceError : CreateAppOnlySteps