mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 01:57:47 +00:00
pmcaptcha web configure
Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
This commit is contained in:
parent
6cbaf243f5
commit
2a1d9e33c1
@ -9,6 +9,7 @@ from io import BytesIO
|
||||
from dataclasses import dataclass, field
|
||||
from random import randint
|
||||
from typing import Optional, Callable, Union, List, Any, Dict, Coroutine
|
||||
from base64 import b64decode, b64encode
|
||||
|
||||
from pyrogram.errors import (FloodWait, AutoarchiveNotAvailable, ChannelsAdminPublicTooMuch,
|
||||
BotResponseTimeout, PeerIdInvalid)
|
||||
@ -29,6 +30,8 @@ from pagermaid.single_utils import sqlite
|
||||
|
||||
cmd_name = "pmcaptcha"
|
||||
|
||||
lang_version = "2.25"
|
||||
|
||||
log_collect_bot = img_captcha_bot = "PagerMaid_Sam_Bot"
|
||||
|
||||
# Get alias for user command
|
||||
@ -87,7 +90,7 @@ def str_timestamp(unix_ts: int) -> str:
|
||||
|
||||
def get_lang_list(): # Yes, blocking
|
||||
from httpx import Client
|
||||
endpoint = f"https://raw.githubusercontent.com/TeamPGM/PMCaptcha-i18n/main/v{get_version()}.py"
|
||||
endpoint = f"https://raw.githubusercontent.com/TeamPGM/PMCaptcha-i18n/main/v{lang_version}.py"
|
||||
for _ in range(3):
|
||||
try:
|
||||
with Client() as client:
|
||||
@ -438,7 +441,7 @@ class Command:
|
||||
"""显示指令帮助信息,使用 <code>,{cmd_name} search [搜索内容]</code> 进行文档、指令(和别名)搜索
|
||||
|
||||
:param opt command: 命令名称
|
||||
:param opt search_str: 搜索的文字,只有 <code>command</code< 为 <code>search</code> 时有效
|
||||
:param opt search_str: 搜索的文字,只有 <code>command</code> 为 <code>search</code> 时有效
|
||||
:alias: h
|
||||
"""
|
||||
help_msg = [f"{code('PMCaptcha')} {lang('cmd_list')}:", ""]
|
||||
@ -1117,6 +1120,35 @@ class Command:
|
||||
setting.set("img_max_retry", number)
|
||||
await self._edit(lang('img_captcha_retry_set') % number)
|
||||
|
||||
async def web_configure(self, config: Optional[str]):
|
||||
"""PMCaptcha 网页可视化配置
|
||||
|
||||
:alias: web
|
||||
"""
|
||||
if not config:
|
||||
config = sqlite[setting.key_name]
|
||||
config['version'] = get_version()
|
||||
config['cmd'] = user_cmd_name
|
||||
for key in ("pass", "banned", "flooded"):
|
||||
if config.get(key):
|
||||
del config[key]
|
||||
config = b64encode(json.dumps(config).encode("utf-8")).decode("utf-8")
|
||||
await self._edit(
|
||||
f"网页配置链接: https://pmc-config.xtaolabs.com/{config}"
|
||||
)
|
||||
return
|
||||
try:
|
||||
nc = json.loads(b64decode(config))
|
||||
except Exception:
|
||||
await self._edit(lang("import_failed"))
|
||||
return
|
||||
for i in nc:
|
||||
if nc[i] == -1:
|
||||
setting.delete(i)
|
||||
else:
|
||||
setting.set(i, nc[i])
|
||||
await self._edit(lang("import_success"))
|
||||
|
||||
|
||||
# region Captcha
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user