diff options
author | clarkzjw <[email protected]> | 2023-02-22 14:01:16 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 12:07:26 -0800 |
commit | ae99c2d7237021e2abb20d4b41a24e0b73028519 (patch) | |
tree | 4c4a2a4d954a51148890d5bf589c938f24633f28 /command.py | |
parent | 75b88bc06d354df64c12497330f124392fa7fc57 (diff) | |
download | swarm2fediverse-ae99c2d7237021e2abb20d4b41a24e0b73028519.tar.gz |
bot: support Mastodon OAuth2 login
test callback
test mastodon callback
test callback
clean customwebhook example
bot: test oauth login
test callback url
test callback
Diffstat (limited to 'command.py')
-rw-r--r-- | command.py | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -4,6 +4,7 @@ from telegram.error import BadRequest | |||
4 | from telegram.ext import ContextTypes, ConversationHandler | 4 | from telegram.ext import ContextTypes, ConversationHandler |
5 | 5 | ||
6 | from config import * | 6 | from config import * |
7 | from mastodon import Mastodon | ||
7 | 8 | ||
8 | 9 | ||
9 | async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | 10 | 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 | |||
13 | return WAIT_LOCATION | 14 | return WAIT_LOCATION |
14 | 15 | ||
15 | 16 | ||
17 | async def fedi_login_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | ||
18 | # generate fedi OAuth login url | ||
19 | |||
20 | # mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=TOOT_API_BASE_URL) | ||
21 | # oauth_url = mastodon_client.auth_request_url(redirect_uris="{}/{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), | ||
22 | # scopes=['write:media', 'write:statuses']) | ||
23 | # | ||
24 | # await update.message.reply_text(PROMPT_FEDI_LOGIN.format(oauth_url), parse_mode=ParseMode.MARKDOWN) | ||
25 | await update.message.reply_text(PROMPT_FEDI_LOGIN_WHERE_IS_INSTANCE, parse_mode=ParseMode.MARKDOWN) | ||
26 | return FEDI_LOGIN | ||
27 | |||
28 | |||
16 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 29 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
17 | await update.message.reply_text(PROMPT_HELP) | 30 | await update.message.reply_text(PROMPT_HELP) |
18 | 31 | ||