aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'command.py')
-rw-r--r--command.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/command.py b/command.py
index e92dc1c..5ae99f6 100644
--- a/command.py
+++ b/command.py
@@ -3,6 +3,7 @@ from 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, delete_user_by_id, update_user_visibility 5from dbstore.peewee_store import get_user_access_key, get_user_home_instance, delete_user_by_id, update_user_visibility
6from dbstore.peewee_store import get_user_by_id, update_delayed_checkin
6from dbstore.peewee_store import TOOT_VISIBILITY_PRIVATE, TOOT_VISIBILITY_UNLISTED, TOOT_VISIBILITY_PUBLIC 7from dbstore.peewee_store import TOOT_VISIBILITY_PRIVATE, TOOT_VISIBILITY_UNLISTED, TOOT_VISIBILITY_PUBLIC
7from config import * 8from config import *
8from util import check_user 9from util import check_user
@@ -54,7 +55,27 @@ async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE, use
54 await update.message.reply_text(PROMPT_LOGOUT_SUCCESS, parse_mode=ParseMode.HTML, reply_markup=LOGIN_MENU) 55 await update.message.reply_text(PROMPT_LOGOUT_SUCCESS, parse_mode=ParseMode.HTML, reply_markup=LOGIN_MENU)
55 56
56 57
57@check_user 58async def delayed_checkin_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
59 await update.message.reply_text(PROMPT_DELAYED_CHECKIN, parse_mode=ParseMode.HTML)
60 return DELAYED_CHECKIN
61
62
63async def callback_delayed_checkin(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
64 try:
65 delayed_minutes = int(update.effective_message.text)
66 except ValueError:
67 await update.message.edit_text(text="Integer expected, try again")
68 return DELAYED_CHECKIN
69
70 if delayed_minutes < 5:
71 delayed_minutes = 0
72
73 update_delayed_checkin(str(update.effective_user.id), delayed_minutes)
74 u = get_user_by_id(str(update.effective_user.id))
75 await update.message.reply_text(text=f"Delayed check-in set to {u['delayed_checkin']} minutes")
76 return ConversationHandler.END
77
78
58async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE, user: User) -> int: 79async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE, user: User) -> int:
59 visibility_menu = InlineKeyboardMarkup([ 80 visibility_menu = InlineKeyboardMarkup([
60 [InlineKeyboardButton("Private", callback_data=TOOT_VISIBILITY_PRIVATE)], 81 [InlineKeyboardButton("Private", callback_data=TOOT_VISIBILITY_PRIVATE)],
Powered by cgit v1.2.3 (git 2.41.0)