AIM client code for Python?

J

Joe Strout

I'd like to write an AIM bot in Python. I found and tried
<http://www.jamwt.com/Py-TOC/>, but it doesn't work for me:

Connecting...
Traceback (most recent call last):
File "aimbot-1.py", line 17, in <module>
bot.go()
File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 62,
in go
self.process_loop()
File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 156,
in process_loop
event = self.recv_event()
File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 230,
in recv_event
dtemp = self._socket.recv(buflen - len(data))
socket.error: (54, 'Connection reset by peer')


I wrote to the author a week ago, but never got a reply. It could be
as simple as changing the server addresses in toc.py, currently:

TOC_SERV_AUTH = ("login.oscar.aol.com", 29999 )
TOC_SERV = ( "toc.oscar.aol.com", 9898 )

....but I don't understand AIM well enough to know the correct values
(and was rather hoping that I wouldn't have to).

Does anyone know how to get Py-TOC to work, or have another Python TOC
implementation to suggest?

Thanks,
- Joe
 
J

Jason Scheirer

I'd like to write an AIM bot in Python.  I found and tried
<http://www.jamwt.com/Py-TOC/>, but it doesn't work for me:

Connecting...
Traceback (most recent call last):
   File "aimbot-1.py", line 17, in <module>
     bot.go()
   File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 62,  
in go
     self.process_loop()
   File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 156,  
in process_loop
     event = self.recv_event()
   File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 230,  
in recv_event
     dtemp = self._socket.recv(buflen - len(data))
socket.error: (54, 'Connection reset by peer')

I wrote to the author a week ago, but never got a reply.  It could be  
as simple as changing the server addresses in toc.py, currently:

TOC_SERV_AUTH = ("login.oscar.aol.com", 29999 )
TOC_SERV = ( "toc.oscar.aol.com", 9898 )

...but I don't understand AIM well enough to know the correct values  
(and was rather hoping that I wouldn't have to).

Does anyone know how to get Py-TOC to work, or have another Python TOC  
implementation to suggest?

Thanks,
- Joe

What I did once to get a bot working was to use Pidgin, and
communicate with the instance of Pidgin over D-Bus. This has the happy
side effect of making the bot multi-protocol and handling all the
connection drop issues and the like, as well as allowing for you to
intervene in conversations.

class HookForAccount(object):
def __init__(self, usernames=None):
if usernames is not None:
if isinstance(usernames, basestring):
usernames = [usernames]
usernames = set([x.lower() for x in usernames])
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject")
self.purple = dbus.Interface(obj,
"im.pidgin.purple.PurpleInterface")
self.accountids = set()
for account in self.purple.PurpleAccountsGetAllActive():
if usernames is None or
self.purple.PurpleAccountGetUsername(account).lower() in usernames:
print self.purple.PurpleAccountGetUsername(account)
self.accountids.add(account)
bus.add_signal_receiver(self.got_im,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")

def got_im(self, code, screenname, message, conversation_id,
flags):
time.sleep(1.75)
self.purple.PurpleConvImSend(self.purple.PurpleConvIm
(conversation_id),
"HELLO!")

if __name__ == "__main__":
logging.getLogger().setLevel(0)
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
HookForAccount(sys.argv[1:] or None)
loop = gobject.MainLoop()
loop.run()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top