From 4e7c19a02a8543325a58bfa67ea674377e86c8ae Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 23 Apr 2011 12:58:35 -0500 Subject: [PATCH] Twitter: use Module's timer support including proper shutdown --- modules/Twitter.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/Twitter.py b/modules/Twitter.py index 32576e4..4b0cc1d 100644 --- a/modules/Twitter.py +++ b/modules/Twitter.py @@ -32,6 +32,11 @@ class Twitter(Module): """Access Twitter via the bot as an authenticated client.""" + def timer_interval(self): + """Check for twitter updates every 300 seconds.""" + + return 300 + def __init__(self, irc, config, server): """Prepare for oauth stuff (but don't execute it yet).""" @@ -92,6 +97,7 @@ class Twitter(Module): def shutdown(self): """Deauth, and make the twitter API item inoperable.""" + Module.shutdown(self) self.twit.ClearCredentials() self.authed = False @@ -233,12 +239,13 @@ class Twitter(Module): return 'The bot is now logged in.' + def timer_do(self): + """Check the timeline.""" + self._check_self_timeline() + def _check_self_timeline(self): """Check my timeline, and if there are entries, print them to the channel.""" - # re-register this check - Timer(300, self._check_self_timeline, ()).start() - if self.authed: # get the id of the last check we made since_id = self._get_last_since_id()