Twitter: use Module's timer support including proper shutdown
This commit is contained in:
parent
80f2ff469c
commit
4e7c19a02a
|
@ -32,6 +32,11 @@ class Twitter(Module):
|
||||||
|
|
||||||
"""Access Twitter via the bot as an authenticated client."""
|
"""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):
|
def __init__(self, irc, config, server):
|
||||||
"""Prepare for oauth stuff (but don't execute it yet)."""
|
"""Prepare for oauth stuff (but don't execute it yet)."""
|
||||||
|
|
||||||
|
@ -92,6 +97,7 @@ class Twitter(Module):
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
"""Deauth, and make the twitter API item inoperable."""
|
"""Deauth, and make the twitter API item inoperable."""
|
||||||
|
|
||||||
|
Module.shutdown(self)
|
||||||
self.twit.ClearCredentials()
|
self.twit.ClearCredentials()
|
||||||
self.authed = False
|
self.authed = False
|
||||||
|
|
||||||
|
@ -233,12 +239,13 @@ class Twitter(Module):
|
||||||
|
|
||||||
return 'The bot is now logged in.'
|
return 'The bot is now logged in.'
|
||||||
|
|
||||||
|
def timer_do(self):
|
||||||
|
"""Check the timeline."""
|
||||||
|
self._check_self_timeline()
|
||||||
|
|
||||||
def _check_self_timeline(self):
|
def _check_self_timeline(self):
|
||||||
"""Check my timeline, and if there are entries, print them to the channel."""
|
"""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:
|
if self.authed:
|
||||||
# get the id of the last check we made
|
# get the id of the last check we made
|
||||||
since_id = self._get_last_since_id()
|
since_id = self._get_last_since_id()
|
||||||
|
|
Loading…
Reference in New Issue