diff --git a/apithreads.py b/apithreads.py index 6ed0e4d..e697e82 100644 --- a/apithreads.py +++ b/apithreads.py @@ -8,6 +8,10 @@ from oauthtwitter import OAuthApi from urllib2 import HTTPError,URLError import avcache +# These are the global constants for the twitter oauth entry for our app +CONSUMER_KEY = jGu64TPCUtyLZKyWyMJldQ +CONSUMER_SECRET = lTRrTyvzRfJab5HsAe16zkV8tqFVRp0k0cTfHL0l4GE + class CustomApi(OAuthApi): ''' @@ -16,13 +20,11 @@ class CustomApi(OAuthApi): instantiated ''' - def __init__(self): - OAuthApi.__init__(self, username, password) + def __init__(self, access_token): + OAuthApi.__init__(self, CONSUMER_KEY, CONSUMER_SECRET, access_token) self.lock = RLock() self.sig_proxy = SigProxy() - self.username = username - thread = GetUserLists(api=self) thread.sig_proxy.connect('lists-ready', self.on_lists_ready) thread.start() @@ -459,3 +461,7 @@ def dms_to_statuses(direct_messages): status.text = dm.text statuses.append(status) return statuses + + +def get_api(username, password): + diff --git a/hrafn.py b/hrafn.py index 018217e..192ce4f 100755 --- a/hrafn.py +++ b/hrafn.py @@ -70,7 +70,7 @@ class Hrafn(): for item in config.sections(): if (re.match(r'account', item)): username = config.get(item, 'username') - self.accounts[username] = apithreads.CustomApi(username=username, password=config.get(item, 'password')) + self.accounts[username] = apithreads.get_api(username=username, password=config.get(item, 'password')) self.accounts[username].sig_proxy.connect('lists-ready', self.on_lists_ready) if not self.db.has_key('active_user'):