diff --git a/collect/twitter_individual.py b/collect/twitter_individual.py index 229e4c0..24dcf05 100644 --- a/collect/twitter_individual.py +++ b/collect/twitter_individual.py @@ -8,3 +8,5 @@ from collect.utils import * if __name__ == '__main__': conf = load_config() + + diff --git a/collect/utils.py b/collect/utils.py index 6dfdd55..d7b6049 100644 --- a/collect/utils.py +++ b/collect/utils.py @@ -1,6 +1,7 @@ import os import json5 +import tweepy def load_config() -> dict: @@ -14,3 +15,16 @@ def load_config() -> dict: return json5.load(f) else: return json5.loads(os.getenv('config')) + + +def tweepy_login(conf: dict) -> tweepy.API: + """ + Login to tweepy + + :param conf: Config from load_config() + :return: Tweepy API object + """ + auth = tweepy.OAuthHandler(conf['consumer_key'], conf['consumer_secret']) + auth.set_access_token(conf['access_token'], conf['access_secret']) + api: tweepy.API = tweepy.API(auth) + return api