Twitter: use Module's timer support including proper shutdown

This commit is contained in:
Brian S. Stephan 2011-04-23 12:58:35 -05:00
parent 80f2ff469c
commit 4e7c19a02a
1 changed files with 10 additions and 3 deletions

View File

@ -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()