From c5faabaf1a9b8e039c8d320d3094c6137dcf27d2 Mon Sep 17 00:00:00 2001 From: devops117 Date: Mon, 14 Mar 2022 09:41:33 +0000 Subject: [PATCH] Format code using black --- SaitamaRobot/__init__.py | 8 +-- SaitamaRobot/__main__.py | 75 ++++++++++++------------ SaitamaRobot/modules/disasters.py | 4 +- SaitamaRobot/modules/get_common_chats.py | 5 +- SaitamaRobot/modules/userinfo.py | 4 +- 5 files changed, 49 insertions(+), 47 deletions(-) diff --git a/SaitamaRobot/__init__.py b/SaitamaRobot/__init__.py index 32a29f2f6c..b74adbe4f9 100644 --- a/SaitamaRobot/__init__.py +++ b/SaitamaRobot/__init__.py @@ -21,9 +21,9 @@ # Config TELEGRAM_BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN") -config_file=Path(os.path.join(__name__, "config.yaml")) -yaml=YAML(typ="safe") -config_data=yaml.load(config_file) # look for ./crawl/config.yaml +config_file = Path(os.path.join(__name__, "config.yaml")) +yaml = YAML(typ="safe") +config_data = yaml.load(config_file) # look for ./crawl/config.yaml OWNER_USERID = int(config_data.get("OWNER_USERID")) OWNER_USERNAME = config_data.get("OWNER_USERNAME") @@ -57,7 +57,7 @@ updater = telegram.ext.Updater(TELEGRAM_BOT_TOKEN) dispatcher = updater.dispatcher -#telethn = TelegramClient( +# telethn = TelegramClient( # "saitama", # env.get("TELEGRAM_API_ID"), env.get("TELEGRAM_API_HASH"), # ) diff --git a/SaitamaRobot/__main__.py b/SaitamaRobot/__main__.py index 035608fc8b..23f17467eb 100644 --- a/SaitamaRobot/__main__.py +++ b/SaitamaRobot/__main__.py @@ -2,46 +2,46 @@ from typing import Optional from telegram import ( - InlineKeyboardButton, - InlineKeyboardMarkup, - ParseMode, - Update, - ) + InlineKeyboardButton, + InlineKeyboardMarkup, + ParseMode, + Update, +) from telegram.error import ( - BadRequest, - ChatMigrated, - NetworkError, - TelegramError, - TimedOut, - Unauthorized, - ) + BadRequest, + ChatMigrated, + NetworkError, + TelegramError, + TimedOut, + Unauthorized, +) from telegram.ext import ( - CallbackContext, - CallbackQueryHandler, - CommandHandler, - Filters, - MessageHandler, - ) + CallbackContext, + CallbackQueryHandler, + CommandHandler, + Filters, + MessageHandler, +) from telegram.ext.dispatcher import DispatcherHandlerStop from telegram.utils.helpers import escape_markdown from SaitamaRobot import ( - ALLOW_EXCL, - CERT_PATH, - dispatcher, - DONATION_LINK, - LOGGER, - OWNER_USERID, - PORT, - StartTime, - SUPPORT_CHAT, - #telethn, - TELEGRAM_BOT_TOKEN, - updater, - URL, - WEBHOOK, - ) + ALLOW_EXCL, + CERT_PATH, + dispatcher, + DONATION_LINK, + LOGGER, + OWNER_USERID, + PORT, + StartTime, + SUPPORT_CHAT, + # telethn, + TELEGRAM_BOT_TOKEN, + updater, + URL, + WEBHOOK, +) from SaitamaRobot.modules import ALL_MODULES from SaitamaRobot.modules.helper_funcs.chat_status import is_user_admin @@ -106,7 +106,8 @@ def get_readable_time(seconds: int) -> str: if DONATION_LINK: DONATE_STRING = ( - f"You can donate to the person currently running me [here]({DONATION_LINK})") + f"You can donate to the person currently running me [here]({DONATION_LINK})" + ) else: DONATE_STRING = """Won't be necessary for now.""" @@ -670,9 +671,9 @@ def main(): LOGGER.info("Using long polling.") updater.start_polling(timeout=15, read_latency=4, drop_pending_updates=True) - #if len(sys.argv) not in (1, 3, 4): + # if len(sys.argv) not in (1, 3, 4): # telethn.disconnect() - #else: + # else: # telethn.run_until_disconnected() updater.idle() @@ -680,5 +681,5 @@ def main(): if __name__ == "__main__": LOGGER.info("Successfully loaded modules: " + str(ALL_MODULES)) - #telethn.start(bot_token=TELEGRAM_BOT_TOKEN) + # telethn.start(bot_token=TELEGRAM_BOT_TOKEN) main() diff --git a/SaitamaRobot/modules/disasters.py b/SaitamaRobot/modules/disasters.py index 1ebe8808e4..6353cf4423 100644 --- a/SaitamaRobot/modules/disasters.py +++ b/SaitamaRobot/modules/disasters.py @@ -21,7 +21,8 @@ from telegram.ext import CallbackContext, CommandHandler from telegram.utils.helpers import mention_html -#TODO: fix addsudo and removesudo +# TODO: fix addsudo and removesudo + def check_user_id(user_id: int, context: CallbackContext) -> Optional[str]: bot = context.bot @@ -138,7 +139,6 @@ def removesudo(update: Update, context: CallbackContext) -> str: return "" - @whitelist_plus def sudolist(update: Update, context: CallbackContext): bot = context.bot diff --git a/SaitamaRobot/modules/get_common_chats.py b/SaitamaRobot/modules/get_common_chats.py index 5847f006f4..2a92488112 100644 --- a/SaitamaRobot/modules/get_common_chats.py +++ b/SaitamaRobot/modules/get_common_chats.py @@ -45,7 +45,10 @@ def get_user_common_chats(update: Update, context: CallbackContext): COMMON_CHATS_HANDLER = CommandHandler( - "getchats", get_user_common_chats, filters=Filters.user(OWNER_USERID), run_async=True + "getchats", + get_user_common_chats, + filters=Filters.user(OWNER_USERID), + run_async=True, ) dispatcher.add_handler(COMMON_CHATS_HANDLER) diff --git a/SaitamaRobot/modules/userinfo.py b/SaitamaRobot/modules/userinfo.py index d9c304562d..e9aa0ca41f 100644 --- a/SaitamaRobot/modules/userinfo.py +++ b/SaitamaRobot/modules/userinfo.py @@ -77,9 +77,7 @@ def get_id(update: Update, context: CallbackContext): @SaitamaTelethonClient.on( - events.NewMessage( - pattern="/ginfo ", from_users=(DRAGONS | DEV_USERS) - ) + events.NewMessage(pattern="/ginfo ", from_users=(DRAGONS | DEV_USERS)) ) async def group_info(event) -> None: chat = event.text.split(" ", 1)[1]