aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot.py')
-rw-r--r--bot.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/bot.py b/bot.py
index 3b45906..79fba5d 100644
--- a/bot.py
+++ b/bot.py
@@ -56,8 +56,11 @@ from config import (
56 LOCATION_CONFIRMATION, 56 LOCATION_CONFIRMATION,
57 ADD_MEDIA, 57 ADD_MEDIA,
58 ADD_COMMENT, 58 ADD_COMMENT,
59 BOT_TOKEN 59 BOT_TOKEN,
60 BOT_SCOPE
60) 61)
62from mastodon import Mastodon
63
61 64
62# Enable logging 65# Enable logging
63logging.basicConfig( 66logging.basicConfig(
@@ -85,7 +88,22 @@ class FediLoginCallbackContext(CallbackContext[ExtBot, dict, dict, dict]):
85 88
86 89
87async def process_oauth_login_callback(update: FediLoginCallbackUpdate, context: FediLoginCallbackContext) -> None: 90async def process_oauth_login_callback(update: FediLoginCallbackUpdate, context: FediLoginCallbackContext) -> None:
88 text = "Login success, your OAuth code is: {}".format(update.code) 91 # query client_id and client_secret from in memory database
92 client_id = ""
93 client_secret = ""
94 home_instance = ""
95
96 mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance)
97 access_token = mastodon_client.log_in(
98 code=update.code,
99 redirect_uri="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL),
100 scopes=BOT_SCOPE
101 )
102
103 # TODO
104 # save access_token to database
105
106 text = "You have successfully logged in to your Mastodon account!"
89 await context.bot.send_message(chat_id=update.state, text=text) 107 await context.bot.send_message(chat_id=update.state, text=text)
90 108
91 109
Powered by cgit v1.2.3 (git 2.41.0)