diff options
-rw-r--r-- | bot.py | 2 | ||||
-rw-r--r-- | command.py | 5 | ||||
-rw-r--r-- | config.py | 5 | ||||
-rw-r--r-- | dbstore/peewee_store.py | 5 | ||||
-rw-r--r-- | prompt/string.py | 1 |
5 files changed, 16 insertions, 2 deletions
@@ -124,6 +124,8 @@ async def main() -> None: | |||
124 | Application.builder().updater(None).token(BOT_TOKEN).context_types(context_types).build() | 124 | Application.builder().updater(None).token(BOT_TOKEN).context_types(context_types).build() |
125 | ) | 125 | ) |
126 | 126 | ||
127 | # TODO: | ||
128 | # check user login status before invoking commands | ||
127 | checkin_handler = ConversationHandler( | 129 | checkin_handler = ConversationHandler( |
128 | entry_points=[ | 130 | entry_points=[ |
129 | CommandHandler("start", start_command), | 131 | CommandHandler("start", start_command), |
@@ -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, get_user_home_instance | 5 | from dbstore.peewee_store import get_user_access_key, get_user_home_instance, delete_user_by_id |
6 | from config import * | 6 | from config import * |
7 | 7 | ||
8 | 8 | ||
@@ -46,7 +46,8 @@ async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No | |||
46 | 46 | ||
47 | 47 | ||
48 | async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 48 | async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
49 | await update.message.reply_text(PROMPT_LOGOUT, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | 49 | if delete_user_by_id(str(update.effective_user.id)): |
50 | await update.message.reply_text(PROMPT_LOGOUT_SUCCESS, parse_mode=ParseMode.HTML, reply_markup=LOGIN_MENU) | ||
50 | 51 | ||
51 | 52 | ||
52 | async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 53 | async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
@@ -19,6 +19,11 @@ MAIN_MENU = ReplyKeyboardMarkup([ | |||
19 | [KeyboardButton(text="/Help")] | 19 | [KeyboardButton(text="/Help")] |
20 | ]) | 20 | ]) |
21 | 21 | ||
22 | LOGIN_MENU = ReplyKeyboardMarkup([ | ||
23 | [KeyboardButton(text="/login")], | ||
24 | [KeyboardButton(text="/Help")] | ||
25 | ]) | ||
26 | |||
22 | SKIP_LOCATION_SEARCH = CALLBACK_SKIP | 27 | SKIP_LOCATION_SEARCH = CALLBACK_SKIP |
23 | INLINE_SKIP_MENU = InlineKeyboardMarkup([ | 28 | INLINE_SKIP_MENU = InlineKeyboardMarkup([ |
24 | [InlineKeyboardButton("Skip", callback_data=SKIP_LOCATION_SEARCH)] | 29 | [InlineKeyboardButton("Skip", callback_data=SKIP_LOCATION_SEARCH)] |
diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py index 2f637bf..f10627b 100644 --- a/dbstore/peewee_store.py +++ b/dbstore/peewee_store.py | |||
@@ -51,6 +51,11 @@ def get_user_access_key(telegram_user_id: str) -> str: | |||
51 | return "" | 51 | return "" |
52 | 52 | ||
53 | 53 | ||
54 | def delete_user_by_id(telegram_user_id: str) -> int: | ||
55 | with db.connection_context(): | ||
56 | return User.delete().where(User.telegram_user_id == telegram_user_id).execute() | ||
57 | |||
58 | |||
54 | def get_user_home_instance(telegram_user_id: str) -> dict: | 59 | def get_user_home_instance(telegram_user_id: str) -> dict: |
55 | with db.connection_context(): | 60 | with db.connection_context(): |
56 | try: | 61 | try: |
diff --git a/prompt/string.py b/prompt/string.py index 207713f..b7aeff1 100644 --- a/prompt/string.py +++ b/prompt/string.py | |||
@@ -42,6 +42,7 @@ PROMPT_HELP = "Available commands:" \ | |||
42 | PROMPT_LIST = "You are linked with the following Fediverse accounts:" | 42 | PROMPT_LIST = "You are linked with the following Fediverse accounts:" |
43 | PROMPT_LIST_NO_RESULT = "You are not linked with any Fediverse account yet. \n\n Input <code>/login</code> to login." | 43 | PROMPT_LIST_NO_RESULT = "You are not linked with any Fediverse account yet. \n\n Input <code>/login</code> to login." |
44 | PROMPT_LOGOUT = "Choose Fediverse account to logout" | 44 | PROMPT_LOGOUT = "Choose Fediverse account to logout" |
45 | PROMPT_LOGOUT_SUCCESS = "Successfully logged out from Fediverse account" | ||
45 | PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" | 46 | PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" |
46 | 47 | ||
47 | CALLBACK_SKIP = "Skip" | 48 | CALLBACK_SKIP = "Skip" |