August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
Deals with post-login messages from the AIM server, mostly by parsing them and sending them out to its "heard" outbox in a slightly more useable form. Also sends messages to the server based on commands coming through its "talk" inbox.
ChatManager expects to receive FLAPs containing SNACs through its "inbox". It recognizes certain types of SNACs. For these SNACS, ChatManager parses them, and sends the relevant data out to its "heard" outbox in tuple format. The following lists the SNACs ChatManager understands and the tuples that it consequently sends out:
SNAC | DESCRIPTION | TUPLE SENT TO "heard" |
---|---|---|
(03, 0b) | Buddy is online | ("buddy online", {name: buddy name}) |
(04, 07) | Incoming message | ("message", sender, message text) |
The "buddy online" message contains a dictionary instead of just a text field for the buddy name because this will make it easier to add more buddy data to a "buddy online" message, such as online time or alias. The server sends this data, but right now ChatManager just discards it.
ChatManager also understands tuple-based commands sent to its "talk" inbox. The following lists the commands it understands, and the corresponding actions it takes.
COMMAND | ACTION |
---|---|
("message", recipient's screenname, message text) | Sends instant message to server (SNAC (04, 07)) |
Simple client with a truly horrible interface:
class AIMHarness(component):
def main(self):
self.loginer = LoginHandler('sitar63112', 'sitar63112').activate()
self.link((self.loginer, "signal"), (self, "internal inbox"))
self.addChildren(self.loginer)
while not self.dataReady("internal inbox"): yield 1
self.oscar = self.recv("internal inbox")
queued = self.recv("internal inbox")
self.unlink(self.oscar)
self.chatter = ChatManager().activate()
self.link((self.chatter, "heard"), (self, "outbox"), passthrough=2)
self.link((self, "inbox"), (self.chatter, "talk"), passthrough=1)
self.link((self.chatter, "outbox"), (self.oscar, "inbox"))
self.link((self.oscar, "outbox"), (self.chatter, "inbox"))
self.link((self, "internal outbox"), (self.chatter, "inbox"))
while len(queued):
self.send(queued[0], "internal outbox")
del(queued[0])
while True:
yield 1
def tuplefy(data):
data = data.split()
if len(data) > 1:
data = ("message", data[0], " ".join(data[1:]))
return data
Pipeline(ConsoleReader(),
PureTransformer(tuplefy),
AIMHarness(),
ConsoleEchoer()
).run()
ChatManager() -> new ChatManager component.
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
strips HTML tags off messages
Main loop.
Extracts the sender and message text from SNAC body, and sends the tuple ("message", sender, message) to "heard".
constructs SNAC (04, 06), the "send message" SNAC and sends it to "outbox"
Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!
Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.
-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT