diff options
author | clarkzjw <[email protected]> | 2023-02-23 21:11:05 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 21:19:14 -0800 |
commit | d7c1835ed41d50d8e0fd42fd8c33fa760ce24bb5 (patch) | |
tree | eecdaec4da3dd914dd72c9bda264b038aee0343b /command.py | |
parent | 1e448735a15b633cb7743a01ce6249a506196ab8 (diff) | |
download | swarm2fediverse-d7c1835ed41d50d8e0fd42fd8c33fa760ce24bb5.tar.gz |
bot: implement /list command
Diffstat (limited to 'command.py')
-rw-r--r-- | command.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -2,7 +2,7 @@ from telegram import Update | |||
2 | from telegram.constants import ParseMode | 2 | from telegram.constants import ParseMode |
3 | from telegram.error import BadRequest | 3 | from telegram.error import BadRequest |
4 | from telegram.ext import ContextTypes, ConversationHandler | 4 | from telegram.ext import ContextTypes, ConversationHandler |
5 | from dbstore.peewee_store import get_user_access_key | 5 | from dbstore.peewee_store import get_user_access_key, get_user_home_instance |
6 | from config import * | 6 | from config import * |
7 | 7 | ||
8 | 8 | ||
@@ -33,7 +33,16 @@ async def tos_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non | |||
33 | 33 | ||
34 | 34 | ||
35 | async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 35 | async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
36 | await update.message.reply_text(PROMPT_LIST, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | 36 | result = get_user_home_instance(str(update.effective_user.id)) |
37 | if len(result) == 0: | ||
38 | await update.message.reply_text(PROMPT_LIST_NO_RESULT, parse_mode=ParseMode.HTML) | ||
39 | else: | ||
40 | await update.message.reply_text(f"You are linked with the following Fediverse accounts:\n\n" | ||
41 | f"<b>Instance</b>: {result['home_instance']}\n" | ||
42 | f"<b>Instance type</b>: {result['home_instance_type']}\n" | ||
43 | f"<b>Default visibility</b>: {result['default_visibility']}\n", | ||
44 | parse_mode=ParseMode.HTML, | ||
45 | reply_markup=MAIN_MENU) | ||
37 | 46 | ||
38 | 47 | ||
39 | async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 48 | async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |