I'm playing about with the idea of making a simple IRC bot. It seems like there is a variety of Python software written for this purpose, with varying feature sets and varying degrees of complexity. I found this package which seems to have a pretty user-friendly interface, and installed it.
I first ran into the problem that the package seems to have been written without Python 3 in mind. I ran the 2to3 converter tool on it and was subsequently able to import the package. However, in trying to replicate the example from the documentation, I get the error in the question title. Here is my script, with the name of the channel removed:
from ircutils import bot
class hambot (bot.SimpleBot):
def on_channel_message (self, event):
if event.message == 'go away hambot':
self.quit('Goodbye.')
def main ():
hb = hambot('hambot')
hb.connect('irc.synirc.org', channel = '(channel name removed)')
hb.start()
if __name__ == '__main__': main()
Here's the result I get when I try to run it. The first exception makes reference only to a script called asynchat.py
, which seems to be a part of Python itself rather than a part of the IRCUtils package, so I am a bit lost as to what the problem might be.
Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import hambot
>>> hambot.main()
Traceback (most recent call last):
File "C:\Python32\lib\asynchat.py", line 243, in initiate_send
data = buffer(first, 0, obs)
File "C:\Python32\lib\asynchat.py", line 56, in buffer
memoryview(obj)
TypeError: cannot make memory view because object does not have the buffer inter
face
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Docs\programs\python\hambot\hambot.py", line 11, in main
hb.start()
File "C:\Python32\lib\site-packages\ircutils\client.py", line 271, in start
self.conn.start()
File "C:\Python32\lib\site-packages\ircutils\connection.py", line 115, in star
t
asyncore.loop(map=self._map)
File "C:\Python32\lib\asyncore.py", line 216, in loop
poll_fun(timeout, map)
File "C:\Python32\lib\asyncore.py", line 162, in poll
write(obj)
File "C:\Python32\lib\asyncore.py", line 95, in write
obj.handle_error()
File "C:\Python32\lib\asyncore.py", line 91, in write
obj.handle_write_event()
File "C:\Python32\lib\asyncore.py", line 466, in handle_write_event
self.handle_write()
File "C:\Python32\lib\asynchat.py", line 194, in handle_write
self.initiate_send()
File "C:\Python32\lib\asynchat.py", line 245, in initiate_send
data = first.more()
AttributeError: 'str' object has no attribute 'more'
>>>
There is one question already on StackOverflow relating to this error message, but the accepted answer states that in that case it relates to a package called "gevent", which as far as I can tell is not even installed on my machine, so I do not think it pertains to this.