aboutsummaryrefslogtreecommitdiff
blob: 579fa48f06f9047cb8d725d74710110b2995c6fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from telegram import Update
from telegram.constants import ParseMode
from telegram.error import BadRequest
from telegram.ext import ContextTypes, ConversationHandler

from config import *


async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
    hello = "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."

    await update.message.reply_text(hello, parse_mode=ParseMode.MARKDOWN)
    await update.message.reply_text(PROMPT_CHOOSE_ACTION, reply_markup=MAIN_MENU)

    return WAIT_LOCATION


async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    await update.message.reply_text(PROMPT_HELP)


async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
    for prompt in [PROMPT_LOCATION_KEYWORD, PROMPT_CHOOSE_POI_FROM_LIST, PROMPT_ADD_COMMENT, PROMPT_ADD_MEDIA]:
        try:
            if context.user_data.get(prompt):
                await context.bot.delete_message(chat_id=update.message.chat_id,
                                                 message_id=context.user_data[prompt])
        except BadRequest as e:
            if "not found" in str(e.message):
                pass
        except Exception as e:
            print(e)

    await update.message.reply_text(text=PROMPT_CANCELED, reply_markup=MAIN_MENU)
    context.user_data.clear()
    return ConversationHandler.END
Powered by cgit v1.2.3 (git 2.41.0)