2012-06-28 19 views
0

我有一個超級簡單的IRC機器人,基本上連接到一個頻道,當有人說「你好機器人」它應該說「你好」在頻道然後退出。然而,雖然我能夠讓它退出,但機器人並不打招呼。錯誤當試圖讓一個Python的irc機器人發送一條消息到頻道

它爲「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 

我使用的腳本是相當短我希望直截了當:

http://pastebin.com/iXwP3YJF

+0

看來,你的pastebin鏈接已損壞。 – Maehler

回答

0

嗯,我想塔t是因爲你使用s作爲套接字,%s作爲字符串。

嘗試這樣做:

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

(即時通訊也創造了在python IRC殭屍的模塊,它沒有這樣做,但還沒有它的功能(不知道是否允許在這裏講這個,如果我不是然後刪除這:) :) https://github.com/FaceHunter/IRCbot

相關問題