Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试让python irc bot向通道发送消息时出错_Python_Irc_Bots - Fatal编程技术网

尝试让python irc bot向通道发送消息时出错

尝试让python irc bot向通道发送消息时出错,python,irc,bots,Python,Irc,Bots,我有一个超级简单的IRC机器人,它基本上连接到一个频道,当有人说“hello robot”时,它应该在频道中说“hello”,然后退出。然而,虽然我可以让机器人退出,但它不会打招呼 它向频道发送“Hello”的代码如下: s.send('PRIVMSG #test :%s\r\n' %s (MESSAGE)) Traceback (most recent call last): File "defaultbot.py", line 40, in <module> s.send('P

我有一个超级简单的IRC机器人,它基本上连接到一个频道,当有人说“hello robot”时,它应该在频道中说“hello”,然后退出。然而,虽然我可以让机器人退出,但它不会打招呼

它向频道发送“Hello”的代码如下:

s.send('PRIVMSG #test :%s\r\n' %s (MESSAGE))
Traceback (most recent call last):
File "defaultbot.py", line 40, in <module>
s.send('PRIVMSG #test :%s\r\n' %s (MESSAGE))
TypeError: '_socketobject' object is not callable
我收到的错误如下:

s.send('PRIVMSG #test :%s\r\n' %s (MESSAGE))
Traceback (most recent call last):
File "defaultbot.py", line 40, in <module>
s.send('PRIVMSG #test :%s\r\n' %s (MESSAGE))
TypeError: '_socketobject' object is not callable
回溯(最近一次呼叫最后一次):
文件“defaultbot.py”,第40行,在
s、 发送('PRIVMSG#测试:%s\r\n'%s(消息))
TypeError:“\u socketobject”对象不可调用
我使用的脚本相当简短,我希望直截了当:


我认为这是因为您使用s作为套接字,使用%s作为字符串

尝试这样做:

s.send('PRIVMSG #test :'+MESSAGE+'\r\n')

(我还在用python为IRC机器人程序创建一个模块,虽然还没有完成,但功能正常(不确定是否允许在此说明,如果不允许,则删除此:)

您的粘贴链接似乎已断开。