Opened 7 years ago

Last modified 7 years ago

#2943 enhancement new

Adding status message (aka available message) support to oscar.py

Reported by: venom087 Owned by:
Priority: normal Milestone:
Component: words Keywords:
Cc: Branch:
Author: Launchpad Bug:

Description

I've been using Twisted Words to write an AIM bot using the oscar protocol. I needed to be able to retrieve users' status messages so I added that functionality to oscar.py. It's just three extra lines of code. The following is a patch with my changes:

Index: /words/protocols/oscar.py
===================================================================
--- /words/protocols/oscar.py	(revision 22046)
+++ /words/protocols/oscar.py	(working copy)
@@ -104,6 +104,7 @@
         self.warning = warn
         self.flags = []
         self.caps = []
+        self.statusMessage = ''
         for k,v in tlvs.items():
             if k == 1: # user flags
                 v=struct.unpack('!H',v)[0]
@@ -161,6 +162,8 @@
                 self.sessionLength = struct.unpack('!L',v)[0]
             elif k == 16: # session length (aol)
                 self.sessionLength = struct.unpack('!L',v)[0]
+            elif k == 29: # status message (aim)
+                self.statusMessage = v[26:len(v)-19]
             elif k == 30: # no idea
                 pass
             else:

Change History (4)

comment:1 follow-up: Changed 7 years ago by exarkun

  • Owner changed from exarkun to venom087

Can you add a unit test for this, too? It would help me understand parts of that patch, such as the magical 26 and 19.

comment:2 in reply to: ↑ 1 Changed 7 years ago by venom087

Replying to exarkun:

magical 26 and 19

I know next to nothing about this protocol. On a hunch I printed the tlvs array passed to the OSCARUser constructor and noticed that item 29 contained the status message, with 26 mysterious characters before it and 19 mysterious characters after it. Unfortunately I can't tell you anything more other than that it's been working for me so far, including for empty status messages.

comment:3 Changed 7 years ago by venom087

  • Owner changed from venom087 to exarkun

comment:4 Changed 3 years ago by <automation>

  • Owner exarkun deleted
Note: See TracTickets for help on using tickets.