diff options
author | clarkzjw <[email protected]> | 2023-02-21 23:32:21 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-21 23:32:21 -0800 |
commit | 3a76618d0f46c7e28641b74a869544661c504e21 (patch) | |
tree | 47af0b7b4dfe9ad5ad6f710c6efe9ab99ab35165 /command.py | |
parent | efc952972f97f98814b2e9a49648766101cd0725 (diff) | |
download | swarm2fediverse-3a76618d0f46c7e28641b74a869544661c504e21.tar.gz |
refactoring code
Diffstat (limited to 'command.py')
-rw-r--r-- | command.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/command.py b/command.py new file mode 100644 index 0000000..753b0a2 --- /dev/null +++ b/command.py | |||
@@ -0,0 +1,33 @@ | |||
1 | from config import * | ||
2 | |||
3 | from telegram import __version__ as TG_VER | ||
4 | from typing import cast, List | ||
5 | from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton | ||
6 | from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, \ | ||
7 | ConversationHandler, CallbackContext | ||
8 | from telegram.constants import ParseMode, ChatAction | ||
9 | from telegram.error import BadRequest | ||
10 | from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardRemove | ||
11 | |||
12 | |||
13 | async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | ||
14 | hello = "Hello, this is `checkin.bot`. \n\n" \ | ||
15 | "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ | ||
16 | "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ | ||
17 | "Aware of privacy concerns, this bot will not store your location data." \ | ||
18 | "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ | ||
19 | "Start using this bot by sharing your location using Telegram context menu to it." | ||
20 | |||
21 | await update.message.reply_text(hello, parse_mode=ParseMode.MARKDOWN) | ||
22 | await update.message.reply_text(PROMPT_CHOOSE_ACTION, reply_markup=MAIN_MENU) | ||
23 | |||
24 | return WAIT_LOCATION | ||
25 | |||
26 | |||
27 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
28 | await update.message.reply_text(PROMPT_HELP) | ||
29 | |||
30 | |||
31 | async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | ||
32 | await update.message.reply_text(text=PROMPT_CANCELED, reply_markup=MAIN_MENU) | ||
33 | return ConversationHandler.END | ||