aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.py2
-rw-r--r--command.py5
-rw-r--r--config.py5
-rw-r--r--dbstore/peewee_store.py5
-rw-r--r--prompt/string.py1
5 files changed, 16 insertions, 2 deletions
diff --git a/bot.py b/bot.py
index 6479460..aea62af 100644
--- a/bot.py
+++ b/bot.py
@@ -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),
diff --git a/command.py b/command.py
index 6feeec7..b12483a 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, get_user_home_instance 5from dbstore.peewee_store import get_user_access_key, get_user_home_instance, delete_user_by_id
6from config import * 6from 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
48async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 48async 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
52async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 53async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
diff --git a/config.py b/config.py
index 83ee37a..9b52205 100644
--- a/config.py
+++ b/config.py
@@ -19,6 +19,11 @@ MAIN_MENU = ReplyKeyboardMarkup([
19 [KeyboardButton(text="/Help")] 19 [KeyboardButton(text="/Help")]
20]) 20])
21 21
22LOGIN_MENU = ReplyKeyboardMarkup([
23 [KeyboardButton(text="/login")],
24 [KeyboardButton(text="/Help")]
25])
26
22SKIP_LOCATION_SEARCH = CALLBACK_SKIP 27SKIP_LOCATION_SEARCH = CALLBACK_SKIP
23INLINE_SKIP_MENU = InlineKeyboardMarkup([ 28INLINE_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
54def 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
54def get_user_home_instance(telegram_user_id: str) -> dict: 59def 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:" \
42PROMPT_LIST = "You are linked with the following 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_LIST_NO_RESULT = "You are not linked with any Fediverse account yet. \n\n Input <code>/login</code> to login."
44PROMPT_LOGOUT = "Choose Fediverse account to logout" 44PROMPT_LOGOUT = "Choose Fediverse account to logout"
45PROMPT_LOGOUT_SUCCESS = "Successfully logged out from Fediverse account"
45PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" 46PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse"
46 47
47CALLBACK_SKIP = "Skip" 48CALLBACK_SKIP = "Skip"
Powered by cgit v1.2.3 (git 2.41.0)