-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbotConfig.py
More file actions
57 lines (46 loc) · 1.61 KB
/
botConfig.py
File metadata and controls
57 lines (46 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from MastodonApi import MastodonApi
#deprecated
#from TwitterApi import TwitterApi
from BlueSkyApi import BlueSkyApi
import logging
import os
logger = logging.getLogger()
# def create_api_twitter():
# consumer_key = os.getenv('CONSUMER_KEY')
# consumer_secret = os.getenv('CONSUMER_SECRET')
# access_token = os.getenv('ACCESS_TOKEN')
# access_token_secret = os.getenv('ACCESS_TOKEN_SECRET')
# t = TwitterApi()
# try:
# api = t.get_api(consumer_key, consumer_secret, access_token, access_token_secret)
# except Exception as e:
# logger.error("Error creating internal API", exc_info=True)
# raise e
# logger.info("API created")
# return t
def create_api_mastodon():
consumer_key = os.getenv('CONSUMER_KEY')
consumer_secret = os.getenv('CONSUMER_SECRET')
access_token = os.getenv('ACCESS_TOKEN')
access_token_secret = ""
m = MastodonApi()
try:
api = m.get_api(consumer_key, consumer_secret, access_token, access_token_secret)
except Exception as e:
logger.error("Error creating internal API", exc_info=True)
raise e
logger.info("API created")
return m
def create_api_bluesky():
consumer_key = os.getenv('CONSUMER_KEY')
consumer_secret = os.getenv('CONSUMER_SECRET')
access_token = os.getenv('ACCESS_TOKEN')
access_token_secret = ""
m = BlueSkyApi()
try:
api = m.get_api(consumer_key, consumer_secret, access_token, access_token_secret)
except Exception as e:
logger.error("Error creating internal API", exc_info=True)
raise e
logger.info("API created")
return m