From e72faecf9cc7d1ae618c0c93130b6e4ed93d36f0 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sun, 18 Apr 2010 11:02:13 -0300 Subject: [PATCH] support for user, groups and hashtags regexps --- mitterlib/network/networkbase.py | 15 +++++++++++++++ mitterlib/network/twitter.py | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/mitterlib/network/networkbase.py b/mitterlib/network/networkbase.py index 6630a43..6a7aad7 100644 --- a/mitterlib/network/networkbase.py +++ b/mitterlib/network/networkbase.py @@ -239,6 +239,21 @@ class NetworkData(object): self.reply_prefix = '' """Prefix to be used in messages when replying to this message.""" + self.user_regexp = None + """Regular expression used to identify usernames in the message. If + the network doesn't support an easy way to identify usernames, it + should be set to None.""" + + self.group_regexp = None + """Regular expression used to identify groups in the message. If the + network doesn't support groups or doesn't have an easy way to + identify groups, it should be set to None.""" + + self.tag_regexps = None + """Regular expression used to identify tags (hashtags) in the + message. If the network doesn't support tags or doesn't have an easy + way to identify groups, it should be set no None.""" + self.network = '' """The network id source of the message. Network classes don't need to worry about this field themselves; :class:`Networks` will set it when diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py index 67441b0..d3bbdbb 100644 --- a/mitterlib/network/twitter.py +++ b/mitterlib/network/twitter.py @@ -171,6 +171,12 @@ class TwitterNetworkData(NetworkData): # them if it becomes a problem. self.message = _unhtml(data['text']) + # regular expression for users + self.user_regexp = r'@[a-zA-Z0-9_]' + + # regular expression for hashtags + self.tag_regexp = r'#[a-zA-Z0-9_]' + return