[+] Create function for tweepy login
This commit is contained in:
@@ -8,3 +8,5 @@ from collect.utils import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
conf = load_config()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user