From 6aafc4e506e2a9aa72955917f031241be4444c67 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 23 Feb 2023 01:09:50 -0800 Subject: bot: add command templates --- bot.py | 12 ++++++++++-- command.py | 18 +++++++++++++++++- config.py | 1 + foursquare/poi.py | 2 -- prompt/string.py | 38 ++++++++++++++++++++++++++++++++------ 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/bot.py b/bot.py index 35884ff..45b2af7 100644 --- a/bot.py +++ b/bot.py @@ -39,7 +39,11 @@ from command import ( start_command, fedi_login_command, cancel_command, - help_command + help_command, + tos_command, + toggle_visibility_command, + logout_command, + list_command ) from config import ( FEDI_LOGIN, @@ -149,7 +153,11 @@ async def main() -> None: ) # register handlers - application.add_handler(CommandHandler("help", help_command)) + application.add_handler(CommandHandler("tos", tos_command)) + application.add_handler(CommandHandler("vis", toggle_visibility_command)) + application.add_handler(CommandHandler("logout", logout_command)) + application.add_handler(CommandHandler("list", list_command)) + application.add_handler(CommandHandler("Help", help_command)) application.add_handler(checkin_handler) application.add_handler(TypeHandler(type=FediLoginCallbackUpdate, callback=process_oauth_login_callback)) diff --git a/command.py b/command.py index 7426901..22f7066 100644 --- a/command.py +++ b/command.py @@ -25,7 +25,23 @@ async def fedi_login_command(update: Update, context: ContextTypes.DEFAULT_TYPE) async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: - await update.message.reply_text(PROMPT_HELP) + await update.message.reply_text(PROMPT_HELP, parse_mode=ParseMode.MARKDOWN, reply_markup=MAIN_MENU) + + +async def tos_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(PROMPT_TOS, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) + + +async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(PROMPT_LIST, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) + + +async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(PROMPT_LOGOUT, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) + + +async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(PROMPT_TOGGLE_VIS, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: diff --git a/config.py b/config.py index d5455a3..b2025ca 100644 --- a/config.py +++ b/config.py @@ -16,6 +16,7 @@ FEDI_LOGIN, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_M MAIN_MENU = ReplyKeyboardMarkup([ [KeyboardButton(text="Check-in here", request_location=True)], + [KeyboardButton(text="/Help")] ]) SKIP_LOCATION_SEARCH = CALLBACK_SKIP diff --git a/foursquare/poi.py b/foursquare/poi.py index ea3509f..39895b7 100644 --- a/foursquare/poi.py +++ b/foursquare/poi.py @@ -1,7 +1,5 @@ import json - import requests - from config import FSQ_API_KEY from dbstore.peewee_store import create_or_update_poi diff --git a/prompt/string.py b/prompt/string.py index a7bf0d1..eda0df8 100644 --- a/prompt/string.py +++ b/prompt/string.py @@ -1,9 +1,23 @@ PROMPT_START = "Hello, this is `checkin.bot`. \n\n" \ - "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ - "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ - "Aware of privacy concerns, this bot will not store your location data." \ - "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ - "Start using this bot by sharing your location using Telegram context menu to it." + "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ + "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ + "Aware of privacy concerns, this bot will not store your location data." \ + "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ + "Start using this bot by sharing your location using Telegram context menu to it." + +PROMPT_TOS = """ +By using this bot, you agree to the following terms of service:\n\n + +Data Collection + +Server Logs + +Server Locations + +Data Sharing +""" + + PROMPT_FEDI_LOGIN_WHERE_IS_INSTANCE = "Where is your home instance in the Fediverse? (e.g. `https://mastodon.social`)" PROMPT_FEDI_LOGIN = "Please login to your Fediverse account by clicking the link below:" PROMPT_CHOOSE_ACTION = "Use bot keyboard to choose an action" @@ -12,9 +26,21 @@ PROMPT_ADD_MEDIA = "You can continue adding photos, or press skip" PROMPT_LOCATION_KEYWORD = "You can input location search keywords or press skip" PROMPT_WAIT_LOCATION_CONFIRMATION_NO_NEARBY_POI = "No nearby places found. But you can input location name manually." PROMPT_WAIT_LOCATION_CONFIRMATION = "Where are you?" -PROMPT_HELP = "Use /start to test this bot." PROMPT_CANCELED = "Canceled" PROMPT_MAX_PHOTO_REACHED = "Cannot attach more than 4 medias, only first 4 will be posted" PROMPT_DONE = "Done" +PROMPT_HELP = "Available commands:" \ + "\n`/login` - login to Fediverse account. " \ + "You can use this command to login to multiple Fediverse accounts" \ + "\n`/list` - list current linked Fediverse accounts" \ + "\n`/logout [number]` - logout from specified Fediverse account, default logout from all" \ + "\n`/vis public|private|unlisted [number]` - " \ + "toggle visibility of your checkins on specified instances, default=private" \ + "\n`/tos` - show ToS message" \ + "\n`/cancel` - cancel current operation during checkins" + +PROMPT_LIST = "List all linked Fediverse accounts" +PROMPT_LOGOUT = "Choose Fediverse account to logout" +PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" CALLBACK_SKIP = "Skip" -- cgit v1.2.3