From 8e83ba6c232172956f4d399e7bfdbe4e832e0536 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Tue, 21 Feb 2023 23:39:21 -0800 Subject: optimize imports --- bot.py | 8 ++++++-- callback.py | 7 ++----- command.py | 13 ++++--------- config.py | 14 -------------- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/bot.py b/bot.py index f2be049..ebb27c9 100644 --- a/bot.py +++ b/bot.py @@ -1,8 +1,12 @@ #!/usr/bin/env python -import logging -from callback import * from telegram.ext import Application, CallbackQueryHandler, CommandHandler, MessageHandler, filters, ConversationHandler +import logging +from callback import callback_skip_media, callback_location_sharing, callback_manual_location, \ + callback_location_confirmation, callback_location_keyword_search, callback_skip_location_keyword, \ + callback_add_comment, callback_skip_comment, callback_add_media +from config import WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_MEDIA, ADD_COMMENT, BOT_TOKEN +from command import start_command, cancel_command, help_command logging.basicConfig( format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO diff --git a/callback.py b/callback.py index 8c80028..687508a 100644 --- a/callback.py +++ b/callback.py @@ -4,14 +4,11 @@ from foursquare.poi import query_poi from dbstore.dbm_store import get_loc from toot import mastodon_client from command import * -from telegram import __version__ as TG_VER from typing import cast, List -from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton -from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, \ - ConversationHandler, CallbackContext +from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardRemove +from telegram.ext import ContextTypes, ConversationHandler, CallbackContext from telegram.constants import ParseMode, ChatAction from telegram.error import BadRequest -from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardRemove async def callback_skip_media(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: diff --git a/command.py b/command.py index 753b0a2..09340fc 100644 --- a/command.py +++ b/command.py @@ -1,13 +1,8 @@ -from config import * +from telegram import Update +from telegram.constants import ParseMode +from telegram.ext import ContextTypes, ConversationHandler -from telegram import __version__ as TG_VER -from typing import cast, List -from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton -from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, \ - ConversationHandler, CallbackContext -from telegram.constants import ParseMode, ChatAction -from telegram.error import BadRequest -from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardRemove +from config import * async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: diff --git a/config.py b/config.py index b690401..ea50a77 100644 --- a/config.py +++ b/config.py @@ -1,19 +1,5 @@ # 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 -- cgit v1.2.3