Skip to content

Instantly share code, notes, and snippets.

@iwillig
Created December 10, 2010 21:03
Show Gist options
  • Select an option

  • Save iwillig/736815 to your computer and use it in GitHub Desktop.

Select an option

Save iwillig/736815 to your computer and use it in GitHub Desktop.
from dispatch import Dispatcher, Message
def print_message(message):
print(message)
print(message.langauge)
print(message.reqex.groups())
dispatcher = Dispatcher()
dispatcher.addMatcher(r'^(bal).(\w+)',print_message)
dispatcher.addMatcher(r'^(solde).(\w+)',print_message,langauge="fr")
dispatcher.addMatcher(r'^(add).(\w+).(\d+)',print_message)
if __name__ == '__main__':
dispatcher.matchMessage(Message(text='bal.cwn926'))
dispatcher.matchMessage(Message(text='solde.cwn926.12354123'))
dispatcher.matchMessage(Message(text='add.cwn926.12312434'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment