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 --- command.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'command.py') diff --git a/command.py b/command.py index 72e1820..837d3cd 100644 --- a/command.py +++ b/command.py @@ -4,6 +4,7 @@ from telegram.error import BadRequest from telegram.ext import ContextTypes, ConversationHandler from config import * +from mastodon import Mastodon async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: @@ -13,6 +14,18 @@ async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> i return WAIT_LOCATION +async def fedi_login_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: + # generate fedi OAuth login url + + # mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=TOOT_API_BASE_URL) + # oauth_url = mastodon_client.auth_request_url(redirect_uris="{}/{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), + # scopes=['write:media', 'write:statuses']) + # + # await update.message.reply_text(PROMPT_FEDI_LOGIN.format(oauth_url), parse_mode=ParseMode.MARKDOWN) + await update.message.reply_text(PROMPT_FEDI_LOGIN_WHERE_IS_INSTANCE, parse_mode=ParseMode.MARKDOWN) + return FEDI_LOGIN + + async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text(PROMPT_HELP) -- cgit v1.2.3