From 3a76618d0f46c7e28641b74a869544661c504e21 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Tue, 21 Feb 2023 23:32:21 -0800 Subject: refactoring code --- config.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'config.py') diff --git a/config.py b/config.py index 3356d11..b690401 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,22 @@ # https://docs.python.org/3/library/configparser.html +from telegram import __version__ as TG_VER + +try: + from telegram import __version_info__ +except ImportError: + __version_info__ = (0, 0, 0, 0, 0) # type: ignore[assignment] + +if __version_info__ < (20, 0, 0, "alpha", 1): + raise RuntimeError( + f"This example is not compatible with your current PTB version {TG_VER}. To view the " + f"{TG_VER} version of this example, " + f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html" + ) + +from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup, KeyboardButton +from prompt.string import * +from typing import TypedDict import configparser config = configparser.ConfigParser() @@ -14,3 +31,22 @@ TOOT_CLIENT_SECRET = config["TOOT"]["CLIENT_SECRET"] TOOT_ACCESS_TOKEN = config["TOOT"]["ACCESS_TOKEN"] MEDIA_GROUP_TIMEOUT = 3 + +WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT = range(5) + +MAIN_MENU = ReplyKeyboardMarkup([ + [KeyboardButton(text="Check-in here", request_location=True)], +]) + +SKIP_LOCATION_SEARCH = CALLBACK_SKIP +INLINE_SKIP_MENU = InlineKeyboardMarkup([ + [InlineKeyboardButton("Skip", callback_data=SKIP_LOCATION_SEARCH)] +]) + + +class MsgDict(TypedDict): + media_id: str + caption: str + status_id: int + content: str + chat_id: int -- cgit v1.2.3