aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.py13
-rw-r--r--dbstore/peewee_store.py13
-rw-r--r--prompt/string.py3
3 files changed, 26 insertions, 3 deletions
diff --git a/command.py b/command.py
index 22f7066..6feeec7 100644
--- a/command.py
+++ b/command.py
@@ -2,7 +2,7 @@ from telegram import Update
2from telegram.constants import ParseMode 2from telegram.constants import ParseMode
3from telegram.error import BadRequest 3from telegram.error import BadRequest
4from telegram.ext import ContextTypes, ConversationHandler 4from telegram.ext import ContextTypes, ConversationHandler
5from dbstore.peewee_store import get_user_access_key 5from dbstore.peewee_store import get_user_access_key, get_user_home_instance
6from config import * 6from 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
35async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 35async 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
39async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 48async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py
index ed52257..2f637bf 100644
--- a/dbstore/peewee_store.py
+++ b/dbstore/peewee_store.py
@@ -51,6 +51,19 @@ def get_user_access_key(telegram_user_id: str) -> str:
51 return "" 51 return ""
52 52
53 53
54def get_user_home_instance(telegram_user_id: str) -> dict:
55 with db.connection_context():
56 try:
57 user = User.get(User.telegram_user_id == telegram_user_id)
58 return {
59 "home_instance": user.home_instance,
60 "home_instance_type": user.home_instance_type,
61 "default_visibility": user.toot_visibility,
62 }
63 except DoesNotExist:
64 return {}
65
66
54class Location(BaseModel): 67class Location(BaseModel):
55 fsq_id = CharField(unique=True, primary_key=True) 68 fsq_id = CharField(unique=True, primary_key=True)
56 name = CharField(max_length=128) 69 name = CharField(max_length=128)
diff --git a/prompt/string.py b/prompt/string.py
index eda0df8..207713f 100644
--- a/prompt/string.py
+++ b/prompt/string.py
@@ -39,7 +39,8 @@ PROMPT_HELP = "Available commands:" \
39 "\n`/tos` - show ToS message" \ 39 "\n`/tos` - show ToS message" \
40 "\n`/cancel` - cancel current operation during checkins" 40 "\n`/cancel` - cancel current operation during checkins"
41 41
42PROMPT_LIST = "List all linked Fediverse accounts" 42PROMPT_LIST = "You are linked with the following Fediverse accounts:"
43PROMPT_LIST_NO_RESULT = "You are not linked with any Fediverse account yet. \n\n Input <code>/login</code> to login."
43PROMPT_LOGOUT = "Choose Fediverse account to logout" 44PROMPT_LOGOUT = "Choose Fediverse account to logout"
44PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" 45PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse"
45 46
Powered by cgit v1.2.3 (git 2.41.0)