meshy / framewirc

An IRC toolkit built upon Python 3's asyncio module
BSD 2-Clause "Simplified" License
35 stars 4 forks source link

Add message parsers #3

Closed meshy closed 8 years ago

meshy commented 9 years ago

These should be useful for handlers. They can either be used to deconstruct messages in handlers themselves, or to make a handler decorator that passes the more semantic arguments into handlers that know what they're getting. eg:

def parse_privmsg(message):
    """Separate a PRIVMSG string into semantically named parts."""
    return {
        'text': message.suffix,
        'sender': message.prefix,
        'target': message.args[0],
    }

This could probably have a better name than parse_privmsg.

meshy commented 9 years ago

Come to think of it, is "parser" even the right word?

meshy commented 9 years ago

The example should probably also list channel.

It should be noted that in 1-to-1 conversation, it may be best to list the sender as the channel, whereas for conversation in an actual #channel, the channel should be the target.

meshy commented 8 years ago

Come to think of it, is "parser" even the right word?

Well, I can't think of a better word.