From d022616c99b22ccbf9269ec05f069c914975a4d9 Mon Sep 17 00:00:00 2001 From: Xtao_dada Date: Wed, 18 Aug 2021 16:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9E=96=20Remove=20unnecessary=20requirement?= =?UTF-8?q?=20(#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ➖ 移除不必要的依赖项 --- pagermaid/__init__.py | 4 +++- pagermaid/assets/config.gen.yml | 42 +++++++++++++++++++++++++++++---- pagermaid/interface/__init__.py | 2 +- pagermaid/listener.py | 2 +- pagermaid/modules/message.py | 2 +- pagermaid/modules/update.py | 2 +- pagermaid/utils.py | 8 +++---- requirements.txt | 1 - 8 files changed, 49 insertions(+), 14 deletions(-) diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 352014d..8e7b52c 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -23,9 +23,11 @@ from json import load as load_json from shutil import copyfile from redis import StrictRedis from logging import getLogger, INFO, DEBUG, ERROR, StreamHandler, basicConfig -from distutils2.util import strtobool +from distutils.util import strtobool from coloredlogs import ColoredFormatter from telethon import TelegramClient + +# Errors from telethon.errors.rpcerrorlist import MessageNotModifiedError, MessageIdInvalidError, ChannelPrivateError, \ ChatSendMediaForbiddenError, YouBlockedUserError, FloodWaitError, ChatWriteForbiddenError, \ AuthKeyDuplicatedError diff --git a/pagermaid/assets/config.gen.yml b/pagermaid/assets/config.gen.yml index 408e829..4689464 100644 --- a/pagermaid/assets/config.gen.yml +++ b/pagermaid/assets/config.gen.yml @@ -7,8 +7,8 @@ # \//_____/ \/ \/ \/ \/ # =================================================================== -# API Credentials of your telegram application created at https://my.telegram.org/apps -api_key: "KEY_HERE" +# API Credentials of your telegram application created at https://my.telegram.org/apps | api_key is api_id +api_key: "ID_HERE" api_hash: "HASH_HERE" # Either debug logging is enabled or not @@ -31,12 +31,17 @@ redis: # Locale settings application_language: "zh-cn" application_region: "China" -application_tts: "cn" +application_tts: "zh-CN" # In-Chat logging settings, default settings logs directly into Kat, strongly advised to change log: "False" log_chatid: "503691334" +# Disabled Built-in Commands +disabled_cmd: + - example1 + - example2 + # Google search preferences result_length: "5" @@ -44,4 +49,33 @@ result_length: "5" width: "1920" height: "1080" background: "#101010" -margin: "20" \ No newline at end of file +margin: "20" + +# socks5 or http or MTProto +proxy_addr: "" +proxy_port: "" +http_addr: "" +http_port: "" +mtp_addr: "" +mtp_port: "" +mtp_secret: "" + +# Apt Git source +git_source: "https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master/" +git_api: "https://api.github.com/repos/Xtao-Labs/PagerMaid-Modify/commits/master" +git_ssh: "https://github.com/Xtao-Labs/PagerMaid-Modify.git" + +# Update Notice +update_check: "True" +update_time: "86400" +update_username: "self" +update_delete: "True" + +# ipv6 +ipv6: "False" + +# Analytics +allow_analytic: "True" + +# speed_test +speed_test_path: "" diff --git a/pagermaid/interface/__init__.py b/pagermaid/interface/__init__.py index 38b4abc..ab77e0f 100644 --- a/pagermaid/interface/__init__.py +++ b/pagermaid/interface/__init__.py @@ -1,7 +1,7 @@ """ PagerMaid web interface utility. """ from threading import Thread -from distutils2.util import strtobool +from distutils.util import strtobool from importlib import import_module from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher from flask import Flask diff --git a/pagermaid/listener.py b/pagermaid/listener.py index 5529d7f..adf40ff 100644 --- a/pagermaid/listener.py +++ b/pagermaid/listener.py @@ -4,7 +4,7 @@ import sys, sentry_sdk, re from telethon import events from telethon.errors import MessageTooLongError -from distutils2.util import strtobool +from distutils.util import strtobool from traceback import format_exc from time import gmtime, strftime, time from telethon.events import StopPropagation diff --git a/pagermaid/modules/message.py b/pagermaid/modules/message.py index 226d73d..78b8d28 100644 --- a/pagermaid/modules/message.py +++ b/pagermaid/modules/message.py @@ -7,7 +7,7 @@ from telethon.tl.functions.messages import DeleteChatUserRequest from telethon.tl.functions.channels import LeaveChannelRequest from telethon.errors import ForbiddenError from telethon.errors.rpcerrorlist import ChatIdInvalidError, FloodWaitError -from distutils2.util import strtobool +from distutils.util import strtobool from pagermaid import bot, log, config from pagermaid.listener import listener from pagermaid.utils import lang, alias_command diff --git a/pagermaid/modules/update.py b/pagermaid/modules/update.py index 00ba08d..d9ff8da 100644 --- a/pagermaid/modules/update.py +++ b/pagermaid/modules/update.py @@ -2,7 +2,7 @@ import platform, json, time import urllib.request -from distutils2.util import strtobool +from distutils.util import strtobool from json import JSONDecodeError from subprocess import run, PIPE from datetime import datetime diff --git a/pagermaid/utils.py b/pagermaid/utils.py index aace9e7..8ece813 100644 --- a/pagermaid/utils.py +++ b/pagermaid/utils.py @@ -18,7 +18,7 @@ def lang(text: str) -> str: return result -def alias_command(command): +def alias_command(command: str) -> str: """ alias """ try: command = alias_dict[command] @@ -108,7 +108,7 @@ async def attach_report(plaintext, file_name, reply_id=None, caption=None): remove(file_name) -async def obtain_message(context): +async def obtain_message(context) -> str: """ Obtains a message from either the reply message or command arguments. """ reply = await context.get_reply_message() message = context.arguments @@ -149,7 +149,7 @@ async def fetch_youtube_audio(url, chat_id, reply_id, string_2): return True -def owoify(text): +def owoify(text: str) -> str: """ Converts your text to OwO """ smileys = [';;w;;', '^w^', '>w<', 'UwU', '(・`ω´・)', '(´・ω・`)'] with open(f"{module_dir}/assets/replacements.json") as fp: @@ -179,6 +179,6 @@ def owoify(text): return text -def clear_emojis(target): +def clear_emojis(target: str) -> str: """ Removes all Emojis from provided string """ return get_emoji_regexp().sub(u'', target) diff --git a/requirements.txt b/requirements.txt index 8a423ca..87f7785 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,6 @@ Telethon>=1.23.0 Pillow>=8.2.0 python-magic>=0.4.24 Pygments>=2.9.0 -distutils2-py3>=1.0a5.dev0 speedtest-cli>=2.1.3 GitPython>=3.1.17 Werkzeug>=2.0.1