From ae99c2d7237021e2abb20d4b41a24e0b73028519 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 22 Feb 2023 14:01:16 -0800 Subject: bot: support Mastodon OAuth2 login test callback test mastodon callback test callback clean customwebhook example bot: test oauth login test callback url test callback --- callback.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'callback.py') diff --git a/callback.py b/callback.py index 2c69fbd..e7a8308 100644 --- a/callback.py +++ b/callback.py @@ -57,6 +57,21 @@ async def process_media_group(context: CallbackContext): await context.bot.send_message(chat_id=chat_id, text=PROMPT_DONE, reply_markup=MAIN_MENU) +async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: + # generate fedi OAuth login url + home_instance = update.effective_message.text + mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=home_instance) + oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), + scopes=['write:media', 'write:statuses'], + state=update.effective_user.id) + + await update.message.reply_text(PROMPT_FEDI_LOGIN, + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Login", url=oauth_url)]]), + parse_mode=ParseMode.MARKDOWN) + + return FEDI_LOGIN + + async def callback_location_sharing(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: if update.message.venue is not None: context.user_data["fsq_id"] = update.message.venue.foursquare_id -- cgit v1.2.3