parent
95628ff0a2
commit
46aa4b5ec4
@ -228,6 +228,13 @@ lang_change_to: The language has been switched to
|
||||
lang_reboot: Restarting.
|
||||
lang_current_lang: The current language is
|
||||
lang_all_lang: "All available languages are "
|
||||
# alias
|
||||
alias_des: Redirect original command.
|
||||
alias_list: 'The following is a list of redirect commands:'
|
||||
alias_no: You have not redirected any original commands.
|
||||
alias_success: Edit redirection command success,PagerMaid-Modify is restarting.
|
||||
alias_exist: Something went wrong, woooo~ The command that is redirected is already occupied.
|
||||
alias_no_exist: Something went wrong, woooo~ The original command is not redirected.
|
||||
# message
|
||||
# id
|
||||
id_des: Get various information about a message.
|
||||
|
@ -240,7 +240,13 @@ lang_change_to: 语言已切换到
|
||||
lang_reboot: 正在重新启动。
|
||||
lang_current_lang: 当前语言是
|
||||
lang_all_lang: 所有可用的语言有:
|
||||
|
||||
## alias
|
||||
alias_des: 重定向原始命令。
|
||||
alias_list: 以下是重定向命令列表:
|
||||
alias_no: 您还没有重定向任何原始命令。
|
||||
alias_success: 编辑重定向命令成功,PagerMaid-Modify 正在重新启动。
|
||||
alias_exist: 出错了呜呜呜 ~ 重定向指向的命令已被占用。
|
||||
alias_no_exist: 出错了呜呜呜 ~ 原始命令没有被重定向。
|
||||
# message
|
||||
## id
|
||||
id_des: 获取一条消息的各种信息。
|
||||
|
@ -223,6 +223,13 @@ lang_change_to: 語言已切換到
|
||||
lang_reboot: 正在重新啟動。
|
||||
lang_current_lang: 目前語言是
|
||||
lang_all_lang: 所有語言有這些:
|
||||
# alias
|
||||
alias_des: 重定向原始命令。
|
||||
alias_list: 以下是重定向命令列表:
|
||||
alias_no: 您還沒有重定向任何原始命令。
|
||||
alias_success: 編輯重定向命令成功,PagerMaid-Modify 正在重新啟動。
|
||||
alias_exist: 出錯了嗚嗚嗚 ~ 重定向指向的命令已被佔用。
|
||||
alias_no_exist: 出錯了嗚嗚嗚 ~ 原始命令沒有被重定向。
|
||||
# message
|
||||
# id
|
||||
id_des: 獲取一條訊息的所有資訊。
|
||||
|
@ -10,6 +10,7 @@ from os import getcwd, makedirs
|
||||
from os.path import exists
|
||||
from sys import version_info, platform
|
||||
from yaml import load, FullLoader, safe_load
|
||||
from json import load as load_json
|
||||
from shutil import copyfile
|
||||
from redis import StrictRedis
|
||||
from logging import getLogger, INFO, DEBUG, ERROR, StreamHandler, basicConfig
|
||||
@ -19,7 +20,6 @@ from telethon import TelegramClient
|
||||
from telethon.errors.rpcerrorlist import MessageNotModifiedError, MessageIdInvalidError
|
||||
from sqlite3 import OperationalError
|
||||
|
||||
|
||||
persistent_vars = {}
|
||||
module_dir = __path__[0]
|
||||
working_dir = getcwd()
|
||||
@ -53,17 +53,31 @@ except Exception as e:
|
||||
print(e)
|
||||
exit(1)
|
||||
|
||||
|
||||
# alias
|
||||
alias_dict: dict = {}
|
||||
|
||||
if exists("data/alias.json"):
|
||||
try:
|
||||
with open("data/alias.json", encoding="utf-8") as f:
|
||||
alias_dict = load_json(f)
|
||||
except Exception as e:
|
||||
print("Reading alias file failed")
|
||||
print(e)
|
||||
exit(1)
|
||||
|
||||
|
||||
def lang(text: str) -> str:
|
||||
""" i18n """
|
||||
result = lang_dict.get(text, text)
|
||||
return result
|
||||
|
||||
|
||||
if strtobool(config['debug']):
|
||||
logs.setLevel(DEBUG)
|
||||
else:
|
||||
logs.setLevel(INFO)
|
||||
|
||||
|
||||
if platform == "linux" or platform == "linux2" or platform == "darwin" or platform == "freebsd7" \
|
||||
or platform == "freebsd8" or platform == "freebsdN" or platform == "openbsd6":
|
||||
logs.info(
|
||||
@ -121,9 +135,11 @@ if not proxy_addr == '' and not proxy_port == '':
|
||||
import socks
|
||||
except:
|
||||
pass
|
||||
bot = TelegramClient("pagermaid", api_key, api_hash, auto_reconnect=True, proxy=(socks.SOCKS5, proxy_addr, int(proxy_port)))
|
||||
bot = TelegramClient("pagermaid", api_key, api_hash, auto_reconnect=True,
|
||||
proxy=(socks.SOCKS5, proxy_addr, int(proxy_port)))
|
||||
elif not mtp_addr == '' and not mtp_port == '' and not mtp_secret == '':
|
||||
from telethon import connection
|
||||
|
||||
bot = TelegramClient("pagermaid", api_key, api_hash, auto_reconnect=True,
|
||||
connection=connection.ConnectionTcpMTProxyRandomizedIntermediate,
|
||||
proxy=(mtp_addr, int(mtp_port), mtp_secret))
|
||||
|
@ -11,11 +11,11 @@ from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
|
||||
from telethon.tl.types import InputPhoto, MessageMediaPhoto, MessageEntityMentionName
|
||||
from struct import error as StructError
|
||||
from pagermaid import bot, log
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
from pagermaid.listener import listener
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="username",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('username'),
|
||||
description=lang('username_des'),
|
||||
parameters="<username>")
|
||||
async def username(context):
|
||||
@ -41,7 +41,7 @@ async def username(context):
|
||||
await log(f"{lang('username_whatset')}`{result}`")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="name",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('name'),
|
||||
description=lang('name_des'),
|
||||
parameters="<first name> <last name>")
|
||||
async def name(context):
|
||||
@ -69,7 +69,7 @@ async def name(context):
|
||||
await log(f"{lang('name_whatset')}`{first_name}`.")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="pfp",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('pfp'),
|
||||
description=lang('pfp_des'))
|
||||
async def pfp(context):
|
||||
""" Sets your profile picture. """
|
||||
@ -99,7 +99,7 @@ async def pfp(context):
|
||||
await context.edit(f"{lang('error_prefix')}{lang('pfp_e_notp')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="bio",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('bio'),
|
||||
description="设置咱的公开情报",
|
||||
parameters="<string>")
|
||||
async def bio(context):
|
||||
@ -116,7 +116,7 @@ async def bio(context):
|
||||
await log(f"{lang('bio_whatset')}`{context.arguments}`.")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="rmpfp",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('rmpfp'),
|
||||
description=lang('rmpfp_des'),
|
||||
parameters=f"<{lang('int')}>")
|
||||
async def rmpfp(context):
|
||||
@ -147,7 +147,7 @@ async def rmpfp(context):
|
||||
await context.edit(f"`{lang('rmpfp_p')}{len(input_photos)} {lang('rmpfp_l')}`")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="profile",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('profile'),
|
||||
description=lang('profile_des'),
|
||||
parameters="<username>")
|
||||
async def profile(context):
|
||||
@ -260,7 +260,7 @@ async def profile(context):
|
||||
await context.edit(caption)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="block",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('block'),
|
||||
description=lang('block_des'),
|
||||
parameters="<username/uid/reply>")
|
||||
async def block_user(context):
|
||||
@ -302,7 +302,7 @@ async def block_user(context):
|
||||
await context.edit(f"`{user}` {lang('block_exist')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="unblock",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('unblock'),
|
||||
description=lang('unblock_des'),
|
||||
parameters="<username/uid/reply>")
|
||||
async def unblock_user(context):
|
||||
|
@ -1,11 +1,11 @@
|
||||
""" PagerMaid module for different ways to avoid users. """
|
||||
|
||||
from pagermaid import redis, log, redis_status
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
from pagermaid.listener import listener
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="ghost",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('ghost'),
|
||||
description=lang('ghost_des'),
|
||||
parameters="<true|false|status>")
|
||||
async def ghost(context):
|
||||
@ -45,7 +45,7 @@ async def ghost(context):
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="deny",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('deny'),
|
||||
description=lang('deny_des'),
|
||||
parameters="<true|false|status>")
|
||||
async def deny(context):
|
||||
|
@ -7,10 +7,10 @@ from pygments.formatters import img
|
||||
from pygments.lexers import guess_lexer
|
||||
from pagermaid import log, module_dir
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import execute, upload_attachment, lang
|
||||
from pagermaid.utils import execute, upload_attachment, lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="convert",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("convert"),
|
||||
description=lang('convert_des'))
|
||||
async def convert(context):
|
||||
""" Converts image to png. """
|
||||
@ -39,7 +39,7 @@ async def convert(context):
|
||||
remove("result.png")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="caption",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("caption"),
|
||||
description=lang('caption_des'),
|
||||
parameters="<string>,<string> <image>")
|
||||
async def caption(context):
|
||||
@ -90,7 +90,7 @@ async def caption(context):
|
||||
await log(f"{lang('caption_success1')} `{message}` {lang('caption_success2')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="ocr",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('ocr'),
|
||||
description=lang('ocr_des'))
|
||||
async def ocr(context):
|
||||
""" Extracts texts from images. """
|
||||
@ -127,7 +127,7 @@ async def ocr(context):
|
||||
remove(target_file_path)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="highlight",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('highlight'),
|
||||
description=lang('highlight_des'),
|
||||
parameters="<string>")
|
||||
async def highlight(context):
|
||||
|
@ -4,10 +4,10 @@ from datetime import datetime
|
||||
from pytz import country_names, country_timezones, timezone
|
||||
from pagermaid import config
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="time",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('time'),
|
||||
description=lang('time_des'),
|
||||
parameters=lang('time_parameters'))
|
||||
async def time(context):
|
||||
|
@ -7,10 +7,10 @@ from gtts import gTTS
|
||||
from re import compile as regex_compile
|
||||
from pagermaid import log
|
||||
from pagermaid.listener import listener, config
|
||||
from pagermaid.utils import clear_emojis, attach_log, fetch_youtube_audio, lang
|
||||
from pagermaid.utils import clear_emojis, attach_log, fetch_youtube_audio, lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="translate",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('translate'),
|
||||
description=lang('translate_des'),
|
||||
parameters=lang('translate_parameters'))
|
||||
async def translate(context):
|
||||
@ -54,7 +54,7 @@ async def translate(context):
|
||||
await log(f"{lang('translate_get')}{translate('translate_from')} {source_lang} {lang('translate_to')} {trans_lang}.")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="tts",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('tts'),
|
||||
description=lang('tts_des'),
|
||||
parameters="<string>")
|
||||
async def tts(context):
|
||||
@ -100,7 +100,7 @@ async def tts(context):
|
||||
await context.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="google",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('google'),
|
||||
description=lang('google_des'),
|
||||
parameters="<query>")
|
||||
async def googletest(context):
|
||||
@ -133,7 +133,7 @@ async def googletest(context):
|
||||
await log(f"{lang('google_success')} `{query}`")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="fetchaudio",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('fetchaudio'),
|
||||
description=lang('fetchaudio_des'),
|
||||
parameters="<url>,<string>")
|
||||
async def fetchaudio(context):
|
||||
|
@ -6,10 +6,10 @@ from telethon.errors.rpcerrorlist import MessageNotModifiedError
|
||||
from cowpy import cow
|
||||
from pagermaid import module_dir
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import owoify, execute, random_gen, obtain_message, lang
|
||||
from pagermaid.utils import owoify, execute, random_gen, obtain_message, lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="animate",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("animate"),
|
||||
description=lang('animate_des'),
|
||||
parameters="<message>")
|
||||
async def animate(context):
|
||||
@ -30,7 +30,7 @@ async def animate(context):
|
||||
count += 1
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="teletype",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("teletype"),
|
||||
description=lang('teletype_des'),
|
||||
parameters="<message>")
|
||||
async def teletype(context):
|
||||
@ -57,7 +57,7 @@ async def teletype(context):
|
||||
await sleep(interval)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="mock",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("mock"),
|
||||
description=lang('mock_des'),
|
||||
parameters="<message>")
|
||||
async def mock(context):
|
||||
@ -80,7 +80,7 @@ async def mock(context):
|
||||
await context.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="widen",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("widen"),
|
||||
description=lang('widen_des'),
|
||||
parameters="<message>")
|
||||
async def widen(context):
|
||||
@ -105,7 +105,7 @@ async def widen(context):
|
||||
await context.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="fox",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("fox"),
|
||||
description=lang('fox_des'),
|
||||
parameters="<message>")
|
||||
async def fox(context):
|
||||
@ -119,7 +119,7 @@ async def fox(context):
|
||||
await edit_reply(result, context)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="owo",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("owo"),
|
||||
description=lang('owo_des'),
|
||||
parameters="<message>")
|
||||
async def owo(context):
|
||||
@ -133,7 +133,7 @@ async def owo(context):
|
||||
await edit_reply(result, context)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="flip",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("flip"),
|
||||
description=lang('flip_des'),
|
||||
parameters="<message>")
|
||||
async def flip(context):
|
||||
@ -147,7 +147,7 @@ async def flip(context):
|
||||
await edit_reply(result, context)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="ship",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("ship"),
|
||||
description=lang('ship_des'),
|
||||
parameters="<username> <username>")
|
||||
async def ship(context):
|
||||
@ -190,7 +190,7 @@ async def ship(context):
|
||||
f"[{target_2.first_name}](tg://user?id={target_2.id}) = ❤️")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="rng",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("rng"),
|
||||
description=lang('rng_des'),
|
||||
parameters="<length>")
|
||||
async def rng(context):
|
||||
@ -207,7 +207,7 @@ async def rng(context):
|
||||
await context.edit(lang('arg_error'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="aaa",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("aaa"),
|
||||
description=lang('aaa_des'),
|
||||
parameters="<integer>")
|
||||
async def aaa(context):
|
||||
@ -224,7 +224,7 @@ async def aaa(context):
|
||||
await context.edit(lang('arg_error'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="asciiart",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("asciiart"),
|
||||
description=lang('asciiart_des'),
|
||||
parameters="<string>")
|
||||
async def asciiart(context):
|
||||
@ -238,7 +238,7 @@ async def asciiart(context):
|
||||
await context.edit(f"```\n{result}\n```")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="tuxsay",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("tuxsay"),
|
||||
description=lang('tuxsay_des'),
|
||||
parameters="<message>")
|
||||
async def tuxsay(context):
|
||||
@ -252,7 +252,7 @@ async def tuxsay(context):
|
||||
await context.edit(f"```\n{result}\n```")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="coin",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("coin"),
|
||||
description=lang('coin_des'))
|
||||
async def coin(context):
|
||||
""" Throws a coin. """
|
||||
|
@ -1,12 +1,14 @@
|
||||
""" The help module. """
|
||||
|
||||
from os import listdir
|
||||
from pagermaid import help_messages
|
||||
from pagermaid.utils import lang
|
||||
from os.path import exists
|
||||
from json import dump as json_dump
|
||||
from pagermaid import help_messages, alias_dict
|
||||
from pagermaid.utils import lang, alias_command
|
||||
from pagermaid.listener import listener, config
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="help",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("help"),
|
||||
description=lang('help_des'),
|
||||
parameters=f"<{lang('command')}>")
|
||||
async def help(context):
|
||||
@ -25,7 +27,7 @@ async def help(context):
|
||||
f"[{lang('help_source')}](https://t.me/PagerMaid_Modify)")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="lang",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("lang"),
|
||||
description=lang('lang_des'))
|
||||
async def lang_change(context):
|
||||
to_lang = context.arguments
|
||||
@ -44,3 +46,47 @@ async def lang_change(context):
|
||||
await context.client.disconnect()
|
||||
else:
|
||||
await context.edit(f'{lang("lang_current_lang")} {config["application_language"]}\n\n{lang("lang_all_lang")}{",".join(ldir)}')
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="alias",
|
||||
description=lang('alias_des'),
|
||||
parameters='{list|del|set} <source> <to>')
|
||||
async def alias_commands(context):
|
||||
source_commands = []
|
||||
to_commands = []
|
||||
texts = []
|
||||
for key, value in alias_dict.items():
|
||||
source_commands.append(key)
|
||||
to_commands.append(value)
|
||||
if len(context.parameter) == 0:
|
||||
await context.edit(lang('arg_error'))
|
||||
return
|
||||
elif len(context.parameter) == 1:
|
||||
if not len(source_commands) == 0:
|
||||
for i in range(0, len(source_commands)):
|
||||
texts.append(f'`{source_commands[i]}` --> `{to_commands[i]}`')
|
||||
await context.edit(lang('alias_list') + '\n\n' + '\n'.join(texts))
|
||||
else:
|
||||
await context.edit(lang('alias_no'))
|
||||
elif len(context.parameter) == 2:
|
||||
source_command = context.parameter[1]
|
||||
try:
|
||||
del alias_dict[source_command]
|
||||
with open("data/alias.json", 'w') as f:
|
||||
json_dump(alias_dict, f)
|
||||
await context.edit(lang('alias_success'))
|
||||
await context.client.disconnect()
|
||||
except KeyError:
|
||||
await context.edit(lang('alias_no_exist'))
|
||||
return
|
||||
elif len(context.parameter) == 3:
|
||||
source_command = context.parameter[1]
|
||||
to_command = context.parameter[2]
|
||||
if to_command in help_messages:
|
||||
await context.edit(lang('alias_exist'))
|
||||
return
|
||||
alias_dict[source_command] = to_command
|
||||
with open("data/alias.json", 'w') as f:
|
||||
json_dump(alias_dict, f)
|
||||
await context.edit(lang('alias_success'))
|
||||
await context.client.disconnect()
|
||||
|
@ -9,10 +9,10 @@ from telethon.errors.rpcerrorlist import ChatIdInvalidError
|
||||
from distutils2.util import strtobool
|
||||
from pagermaid import bot, log, config
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="id",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("id"),
|
||||
description=lang('id_des'))
|
||||
async def userid(context):
|
||||
""" Query the UserID of the sender of the message you replied to. """
|
||||
@ -80,7 +80,7 @@ async def userid(context):
|
||||
await context.edit(text)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="uslog",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("uslog"),
|
||||
description=lang('uslog_des'),
|
||||
parameters="<string>")
|
||||
async def uslog(context):
|
||||
@ -99,7 +99,7 @@ async def uslog(context):
|
||||
await context.edit(lang('uslog_log_disable'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="log",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("log"),
|
||||
description=lang('log_des'),
|
||||
parameters="<string>")
|
||||
async def logging(context):
|
||||
@ -118,7 +118,7 @@ async def logging(context):
|
||||
await context.edit(lang('uslog_log_disable'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="re",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("re"),
|
||||
description=lang('re_des'),
|
||||
parameters=lang('re_parameters'))
|
||||
async def re(context):
|
||||
@ -143,7 +143,7 @@ async def re(context):
|
||||
await context.edit(lang('not_reply'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="leave",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("leave"),
|
||||
description=lang('leave_res'))
|
||||
async def leave(context):
|
||||
""" It leaves you from the group. """
|
||||
@ -159,7 +159,7 @@ async def leave(context):
|
||||
await context.edit(lang('leave_not_group'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="meter2feet",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("meter2feet"),
|
||||
description=lang('m2f_des'),
|
||||
parameters="<meters>")
|
||||
async def meter2feet(context):
|
||||
@ -172,7 +172,7 @@ async def meter2feet(context):
|
||||
await context.edit(f"{lang('m2f_get')} {str(meter)}{lang('m2f_meter')} {lang('m2f_covert_to')} {str(feet)}{lang('m2f_feet')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="feet2meter",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("feet2meter"),
|
||||
description=lang('f2m_des'),
|
||||
parameters="<feet>")
|
||||
async def feet2meter(context):
|
||||
@ -185,7 +185,7 @@ async def feet2meter(context):
|
||||
await context.edit(f"{lang('m2f_get')} {str(feet)} {lang('m2f_feet')}{lang('m2f_covert_to')} {str(meter)}{lang('m2f_meter')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="hitokoto",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("hitokoto"),
|
||||
description=lang('hitokoto_des'))
|
||||
async def hitokoto(context):
|
||||
""" Get hitokoto.cn """
|
||||
|
@ -9,7 +9,7 @@ from shutil import copyfile, move
|
||||
from glob import glob
|
||||
from pagermaid import log, working_dir
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import upload_attachment, lang
|
||||
from pagermaid.utils import upload_attachment, lang, alias_command
|
||||
from pagermaid.modules import plugin_list as active_plugins, __list_plugins
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ def update_version(plugin_name, version):
|
||||
json.dump(version_json, f)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="apt", diagnostics=False,
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('apt'), diagnostics=False,
|
||||
description=lang('apt_des'),
|
||||
parameters=lang('apt_parameters'))
|
||||
async def plugin(context):
|
||||
|
@ -4,10 +4,10 @@ from asyncio import sleep
|
||||
from telethon.errors.rpcbaseerrors import BadRequestError
|
||||
from pagermaid import log
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="prune",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command('prune'),
|
||||
description=lang('prune_des'))
|
||||
async def prune(context):
|
||||
""" Purge every single message after the message you replied to. """
|
||||
@ -33,7 +33,7 @@ async def prune(context):
|
||||
await notification.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="selfprune",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("selfprune"),
|
||||
description=lang('sp_des'),
|
||||
parameters=lang('sp_parameters'))
|
||||
async def selfprune(context):
|
||||
@ -59,7 +59,7 @@ async def selfprune(context):
|
||||
await notification.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="yourprune",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("yourprune"),
|
||||
description=lang('yp_des'),
|
||||
parameters=lang('sp_parameters'))
|
||||
async def yourprune(context):
|
||||
@ -91,7 +91,7 @@ async def yourprune(context):
|
||||
await notification.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="del",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("del"),
|
||||
description=lang('del_des'))
|
||||
async def delete(context):
|
||||
""" Deletes the message you replied to. """
|
||||
|
@ -6,10 +6,10 @@ from pyzbar.pyzbar import decode
|
||||
from PIL import Image
|
||||
from pagermaid import log
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import obtain_message, upload_attachment, lang
|
||||
from pagermaid.utils import obtain_message, upload_attachment, lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="genqr",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("genqr"),
|
||||
description=lang('genqr_des'),
|
||||
parameters="<string>")
|
||||
async def genqr(context):
|
||||
@ -32,7 +32,7 @@ async def genqr(context):
|
||||
await log(f"`{message}` {lang('genqr_ok')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="parseqr",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("parseqr"),
|
||||
description=lang('parseqr_des'))
|
||||
async def parseqr(context):
|
||||
""" Parse attachment of replied message as a QR Code and output results. """
|
||||
|
@ -17,7 +17,7 @@ from pathlib import Path
|
||||
from pagermaid import log, config, redis_status
|
||||
from pagermaid.utils import execute, upload_attachment
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
|
||||
DCs = {
|
||||
1: "149.154.175.50",
|
||||
@ -28,7 +28,7 @@ DCs = {
|
||||
}
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="sysinfo",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("sysinfo"),
|
||||
description=lang('sysinfo_des'))
|
||||
async def sysinfo(context):
|
||||
""" Retrieve system information via neofetch. """
|
||||
@ -37,7 +37,7 @@ async def sysinfo(context):
|
||||
await context.edit(f"`{result}`")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="fortune",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("fortune"),
|
||||
description=lang('fortune_des'))
|
||||
async def fortune(context):
|
||||
""" Reads a fortune cookie. """
|
||||
@ -48,7 +48,7 @@ async def fortune(context):
|
||||
await context.edit(result)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="fbcon",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("fbcon"),
|
||||
description=lang('fbcon_des'))
|
||||
async def tty(context):
|
||||
""" Screenshots a TTY and prints it. """
|
||||
@ -79,7 +79,7 @@ async def tty(context):
|
||||
await log("Screenshot of binded framebuffer console taken.")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="status",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("status"),
|
||||
description=lang('status_des'))
|
||||
async def status(context):
|
||||
database = lang('status_online') if redis_status() else lang('status_offline')
|
||||
@ -98,7 +98,7 @@ async def status(context):
|
||||
await context.edit(text)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="speedtest",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("speedtest"),
|
||||
description=lang('speedtest_des'))
|
||||
async def speedtest(context):
|
||||
""" Tests internet speed using speedtest. """
|
||||
@ -173,7 +173,7 @@ async def speedtest(context):
|
||||
await context.delete()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="connection",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("connection"),
|
||||
description=lang('connection_des'))
|
||||
async def connection(context):
|
||||
""" Displays connection information between PagerMaid and Telegram. """
|
||||
@ -186,7 +186,7 @@ async def connection(context):
|
||||
)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="pingdc",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("pingdc"),
|
||||
description=lang('pingdc_des'))
|
||||
async def pingdc(context):
|
||||
""" Ping your or other data center's IP addresses. """
|
||||
@ -203,7 +203,7 @@ async def pingdc(context):
|
||||
)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="ping",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("ping"),
|
||||
description=lang('ping_des'))
|
||||
async def ping(context):
|
||||
""" Calculates latency between PagerMaid and Telegram. """
|
||||
@ -214,7 +214,7 @@ async def ping(context):
|
||||
await context.edit(f"Pong!|{duration}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="topcloud",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("topcloud"),
|
||||
description=lang('topcloud_des'))
|
||||
async def topcloud(context):
|
||||
""" Generates a word cloud of resource-hungry processes. """
|
||||
|
@ -12,11 +12,11 @@ from PIL import Image, ImageOps
|
||||
from math import floor
|
||||
from pagermaid import bot, redis, redis_status
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
from pagermaid.utils import lang, alias_command
|
||||
from pagermaid import log
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="s",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("s"),
|
||||
description=lang('sticker_des'),
|
||||
parameters="<emoji>")
|
||||
async def sticker(context):
|
||||
|
@ -8,12 +8,12 @@ from asyncio import sleep
|
||||
from requests.exceptions import MissingSchema, InvalidURL, ConnectionError
|
||||
from pagermaid import log, bot
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import attach_log, execute, lang
|
||||
from pagermaid.utils import attach_log, execute, lang, alias_command
|
||||
from telethon.errors.rpcerrorlist import UserAlreadyParticipantError
|
||||
from telethon.tl.functions.messages import ImportChatInviteRequest
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="sh",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("sh"),
|
||||
description=lang('sh_des'),
|
||||
parameters=lang('sh_parameters'))
|
||||
async def sh(context):
|
||||
@ -64,7 +64,7 @@ async def sh(context):
|
||||
await log(f"{lang('sh_success')}: `{command}`")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="restart", diagnostics=False,
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("restart"), diagnostics=False,
|
||||
description=lang('restart_des'))
|
||||
async def restart(context):
|
||||
""" To re-execute PagerMaid. """
|
||||
@ -74,7 +74,7 @@ async def restart(context):
|
||||
await context.client.disconnect()
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="trace",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("trace"),
|
||||
description=lang('trace_des'),
|
||||
parameters="<url>")
|
||||
async def trace(context):
|
||||
@ -115,7 +115,7 @@ async def trace(context):
|
||||
await context.edit(lang('arg_error'))
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="chat",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("chat"),
|
||||
description=lang('chat_des'))
|
||||
async def contact_chat(context):
|
||||
""" join a chatroom. """
|
||||
|
@ -10,10 +10,10 @@ from git import Repo
|
||||
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
|
||||
from pagermaid import log
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import execute, lang
|
||||
from pagermaid.utils import execute, lang, alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="update",
|
||||
@listener(is_plugin=False, outgoing=True, command=alias_command("update"),
|
||||
description=lang('update_des'),
|
||||
parameters="<true/debug>")
|
||||
async def update(context):
|
||||
|
@ -9,7 +9,7 @@ from re import sub, IGNORECASE
|
||||
from asyncio import create_subprocess_shell
|
||||
from asyncio.subprocess import PIPE
|
||||
from youtube_dl import YoutubeDL
|
||||
from pagermaid import module_dir, bot, lang_dict
|
||||
from pagermaid import module_dir, bot, lang_dict, alias_dict
|
||||
|
||||
|
||||
def lang(text: str) -> str:
|
||||
@ -18,6 +18,15 @@ def lang(text: str) -> str:
|
||||
return result
|
||||
|
||||
|
||||
def alias_command(command):
|
||||
""" alias """
|
||||
try:
|
||||
command = alias_dict[command]
|
||||
except KeyError:
|
||||
pass
|
||||
return command
|
||||
|
||||
|
||||
async def upload_attachment(file_path, chat_id, reply_id, caption=None, preview=None, document=None):
|
||||
""" Uploads a local attachment file. """
|
||||
if not exists(file_path):
|
||||
|
Loading…
Reference in New Issue
Block a user