mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-25 13:12:17 +00:00
CI: Alpha source
This commit is contained in:
parent
2ecdca9c3b
commit
c317d4ba6f
3
.github/workflows/python.yml
vendored
3
.github/workflows/python.yml
vendored
@ -8,6 +8,7 @@ on:
|
|||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/**'
|
- '.github/**'
|
||||||
- 'list.json'
|
- 'list.json'
|
||||||
|
- 'alpha/list.json'
|
||||||
- 'telegram_update.py'
|
- 'telegram_update.py'
|
||||||
- 'update_list.py'
|
- 'update_list.py'
|
||||||
- 'telegraph_update.py'
|
- 'telegraph_update.py'
|
||||||
@ -49,4 +50,4 @@ jobs:
|
|||||||
# Optional. Commit message for the created commit.
|
# Optional. Commit message for the created commit.
|
||||||
# Defaults to "Apply automatic changes"
|
# Defaults to "Apply automatic changes"
|
||||||
commit_message: "CI: Update version json"
|
commit_message: "CI: Update version json"
|
||||||
file_pattern: 'list.json'
|
file_pattern: 'list.json alpha/list.json'
|
||||||
|
42
alpha/index.html
Normal file
42
alpha/index.html
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<title>无法访问!</title>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
|
||||||
|
<meta name="robots" content="noindex, nofollow"/>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/>
|
||||||
|
<link rel="stylesheet" id="cf_styles-css" href="https://cloudflare.com/cdn-cgi/styles/cf.errors.css" type="text/css"
|
||||||
|
media="screen,projection"/>
|
||||||
|
<link rel="stylesheet" id='cf_styles-ie-css' href="https://cloudflare.com/cdn-cgi/styles/cf.errors.ie.css"
|
||||||
|
type="text/css" media="screen,projection"/>
|
||||||
|
<style type="text/css">body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0
|
||||||
|
}</style>
|
||||||
|
<script type="text/javascript" src="https://cloudflare.com/cdn-cgi/scripts/zepto.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cloudflare.com/cdn-cgi/scripts/cf.common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="cf-wrapper">
|
||||||
|
<div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">
|
||||||
|
请启用cookie。
|
||||||
|
</div>
|
||||||
|
<div id="cf-error-details" class="cf-error-details-wrapper">
|
||||||
|
<div class="cf-wrapper cf-header cf-error-overview">
|
||||||
|
<h1 data-translate="block_headline">抱歉,您已被阻止</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cf-section cf-highlight">
|
||||||
|
<div class="cf-wrapper">
|
||||||
|
<div class="cf-screenshot-container cf-screenshot-full">
|
||||||
|
|
||||||
|
<span class="cf-no-screenshot error"></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
3
alpha/list.json
Normal file
3
alpha/list.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"list": []
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
向别人的消息自动回复Emoji
|
|
@ -1,263 +0,0 @@
|
|||||||
"""
|
|
||||||
自动回复Emoji插件
|
|
||||||
Author: SuperManito
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pagermaid import bot, log
|
|
||||||
from pagermaid.single_utils import sqlite
|
|
||||||
from pagermaid.enums import Client, Message
|
|
||||||
from pagermaid.utils import lang, edit_delete, pip_install
|
|
||||||
from pagermaid.listener import listener
|
|
||||||
|
|
||||||
pip_install("emoji")
|
|
||||||
|
|
||||||
import emoji
|
|
||||||
|
|
||||||
|
|
||||||
# 获取内容中的表情符号,并用|分割
|
|
||||||
def get_emoji(text):
|
|
||||||
if emojiArr := emoji.distinct_emoji_list(text):
|
|
||||||
delimiter = '|'
|
|
||||||
return delimiter.join(emojiArr)
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=False,
|
|
||||||
outgoing=True,
|
|
||||||
command="auto_send_reactions",
|
|
||||||
description='\n自动回复Emoji插件',
|
|
||||||
parameters="`\n自动回复Emoji插件,支持同时设置多个目标生效用户,目前仅支持回复用户在群组中发送的消息,默认在所有已加入的群组中生效\n"
|
|
||||||
"\n**设置插件状态**:"
|
|
||||||
"\n启用:`,auto_send_reactions enable`"
|
|
||||||
"\n停用:`,auto_send_reactions disable`"
|
|
||||||
"\n\n**设置目标生效用户**:"
|
|
||||||
"\n添加:`,auto_send_reactions set <用户id/用户名> <表情内容>`"
|
|
||||||
"\n移除:`,auto_send_reactions unset <用户id/用户名>`"
|
|
||||||
"\n支持直接回复消息以进行快速设置,可以省略用户标识参数"
|
|
||||||
"\n\n**设置生效群组黑名单**:"
|
|
||||||
"\n添加:`,auto_send_reactions block <群组id/群组用户名>`"
|
|
||||||
"\n移除:`,auto_send_reactions unblock <群组id/群组用户名>\n")
|
|
||||||
async def AutoSendReactions(client: Client, message: Message):
|
|
||||||
reply = message.reply_to_message
|
|
||||||
|
|
||||||
# 启用插件
|
|
||||||
if message.parameter[0] == "enable":
|
|
||||||
# for ID in ID_FROM_ARRAY :
|
|
||||||
# # 检查来源频道/群组
|
|
||||||
# try:
|
|
||||||
# channel = await bot.get_chat(ID)
|
|
||||||
# except Exception as e:
|
|
||||||
# errorMsg = f"第{e.__traceback__.tb_lineno}行:{e}"
|
|
||||||
# await message.edit(f"出错了呜呜呜 ~ 无法识别的来源对话。\n\n{errorMsg}")
|
|
||||||
# return
|
|
||||||
|
|
||||||
if not sqlite.get("AutoSendReactions.Enable"):
|
|
||||||
sqlite["AutoSendReactions.Enable"] = 'yes'
|
|
||||||
|
|
||||||
# 返回消息
|
|
||||||
await edit_delete(message, "✅ **已启用自动回复表情插件**")
|
|
||||||
|
|
||||||
elif message.parameter[0] == "disable":
|
|
||||||
|
|
||||||
if sqlite.get("AutoSendReactions.Enable"):
|
|
||||||
del sqlite["AutoSendReactions.Enable"]
|
|
||||||
|
|
||||||
# 返回消息
|
|
||||||
await edit_delete(message, "❌ **已停用自动回复表情插件**")
|
|
||||||
|
|
||||||
elif message.parameter[0] in ["set", "unset"]:
|
|
||||||
|
|
||||||
## 设置插件
|
|
||||||
if (message.parameter[0] == "set"):
|
|
||||||
|
|
||||||
if not reply and (len(message.parameter) == 3):
|
|
||||||
target = message.parameter[1]
|
|
||||||
content = message.parameter[2]
|
|
||||||
try:
|
|
||||||
# 获取用户信息
|
|
||||||
user_info = await bot.get_users(target)
|
|
||||||
# 判断参数合法性
|
|
||||||
if not user_info:
|
|
||||||
return await message.edit("❌ **目标用户不存在或参数有误**")
|
|
||||||
if not content or not get_emoji(content):
|
|
||||||
return await message.edit("❌ **Emoji参数不能为空或不合法**")
|
|
||||||
user_name = (
|
|
||||||
f'{user_info.first_name} {user_info.last_name}'
|
|
||||||
if user_info.last_name
|
|
||||||
else user_info.first_name
|
|
||||||
)
|
|
||||||
# 设置或更新
|
|
||||||
hasSetted = sqlite.get(f"AutoSendReactions.{target}")
|
|
||||||
sqlite[f"AutoSendReactions.{target}"] = content
|
|
||||||
await edit_delete(
|
|
||||||
message,
|
|
||||||
f"✅ 已{'更新' if hasSetted else '添加'}对 __{user_name}__ 的自动回复Emoji设置**"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await message.edit(message, f"❌ **在设置中遇到了一些错误** > {e}")
|
|
||||||
await log(e) # 打印错误日志
|
|
||||||
|
|
||||||
elif reply and (len(message.parameter) == 2):
|
|
||||||
from_user = reply.from_user
|
|
||||||
target = from_user.id
|
|
||||||
content = message.parameter[1]
|
|
||||||
try:
|
|
||||||
# 判断参数合法性
|
|
||||||
if not content or not get_emoji(content):
|
|
||||||
return await message.edit("❌ **Emoji参数不能为空或不合法**")
|
|
||||||
user_name = (
|
|
||||||
f'{from_user.first_name} {from_user.last_name}'
|
|
||||||
if from_user.last_name
|
|
||||||
else from_user.first_name
|
|
||||||
)
|
|
||||||
# 设置或更新
|
|
||||||
hasSetted = sqlite.get(f"AutoSendReactions.{target}")
|
|
||||||
sqlite[f"AutoSendReactions.{target}"] = content
|
|
||||||
await edit_delete(
|
|
||||||
message,
|
|
||||||
f"✅ 已{'更新' if hasSetted else '添加'}对 __{user_name}__ 的自动回复Emoji设置"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await message.edit(message, f"❌ **在设置中遇到了一些错误** > {e}")
|
|
||||||
await log(e) # 打印错误日志
|
|
||||||
else:
|
|
||||||
return await message.edit(
|
|
||||||
f"{lang('error_prefix')}{lang('arg_error')}")
|
|
||||||
|
|
||||||
elif (message.parameter[0] == "unset"):
|
|
||||||
|
|
||||||
if not reply and (len(message.parameter) == 2):
|
|
||||||
target = message.parameter[1]
|
|
||||||
try:
|
|
||||||
# 获取用户信息
|
|
||||||
user_info = await bot.get_users(target)
|
|
||||||
# 判断参数合法性
|
|
||||||
if not user_info:
|
|
||||||
return await message.edit("❌ **目标用户不存在或参数有误**")
|
|
||||||
user_id = user_info.id
|
|
||||||
user_name = (
|
|
||||||
f'{user_info.first_name} {user_info.last_name}'
|
|
||||||
if user_info.last_name
|
|
||||||
else user_info.first_name
|
|
||||||
)
|
|
||||||
if hasSetted := sqlite.get(f"AutoSendReactions.{user_id}"):
|
|
||||||
del sqlite[f"AutoSendReactions.{user_id}"]
|
|
||||||
await edit_delete(
|
|
||||||
message, f"✅ 对 __{user_name}__ 的自动回复Emoji设置已删除")
|
|
||||||
else:
|
|
||||||
await edit_delete(
|
|
||||||
message, f"❌ 还没有对 __{user_name}__ 设置自动回复Emoji哦~")
|
|
||||||
except Exception as e:
|
|
||||||
await message.edit(message, f"❌ **在设置中遇到了一些错误** > {e}")
|
|
||||||
await log(e) # 打印错误日志
|
|
||||||
|
|
||||||
elif reply and (len(message.parameter) == 1):
|
|
||||||
from_user = reply.from_user
|
|
||||||
target = from_user.id
|
|
||||||
try:
|
|
||||||
user_name = (
|
|
||||||
f'{from_user.first_name} {from_user.last_name}'
|
|
||||||
if from_user.last_name
|
|
||||||
else from_user.first_name
|
|
||||||
)
|
|
||||||
if hasSetted := sqlite.get(f"AutoSendReactions.{target}"):
|
|
||||||
del sqlite[f"AutoSendReactions.{target}"]
|
|
||||||
await edit_delete(
|
|
||||||
message, f"✅ 已删除对 __{user_name}__ 的自动回复Emoji设置")
|
|
||||||
else:
|
|
||||||
await edit_delete(
|
|
||||||
message, f"❌ 还没有对 __{user_name}__ 设置自动回复Emoji哦~")
|
|
||||||
except Exception as e:
|
|
||||||
await message.edit(message, f"❌ **在设置中遇到了一些错误** > {e}")
|
|
||||||
await log(e) # 打印错误日志
|
|
||||||
else:
|
|
||||||
return await message.edit(
|
|
||||||
f"{lang('error_prefix')}{lang('arg_error')}")
|
|
||||||
|
|
||||||
else:
|
|
||||||
return await message.edit(
|
|
||||||
f"{lang('error_prefix')}{lang('arg_error')}")
|
|
||||||
|
|
||||||
elif (message.parameter[0]
|
|
||||||
== "block") or (message.parameter[0] == "unblock") and (len(
|
|
||||||
message.parameter) == 2):
|
|
||||||
group = message.parameter[1]
|
|
||||||
group_info = await bot.get_chat(chat_id=group)
|
|
||||||
if not group_info:
|
|
||||||
return await message.edit("❌ **目标群组不存在或参数有误**")
|
|
||||||
group_id = group_info.id
|
|
||||||
group_name = group_info.title
|
|
||||||
|
|
||||||
if (message.parameter[0] == "block"):
|
|
||||||
if hasBlocked := sqlite.get(f"AutoSendReactionsBlock.{group_id}"):
|
|
||||||
await edit_delete(
|
|
||||||
message, f"❌ 已经将 __{group_name}__ 加入自动回复Emoji黑名单群组了哦~")
|
|
||||||
else:
|
|
||||||
sqlite[f"AutoSendReactionsBlock.{group_id}"] = 'yes'
|
|
||||||
await edit_delete(message,
|
|
||||||
f"✅ 已将 __{group_name}__ 加入至自动回复Emoji黑名单群组")
|
|
||||||
elif (message.parameter[0] == "unblock"):
|
|
||||||
if hasBlocked := sqlite.get(f"AutoSendReactionsBlock.{group_id}"):
|
|
||||||
del sqlite[f"AutoSendReactionsBlock.{group_id}"]
|
|
||||||
await edit_delete(message,
|
|
||||||
f"✅ 已将 __{group_name}__ 从自动回复Emoji黑名单群组中移除")
|
|
||||||
else:
|
|
||||||
await edit_delete(
|
|
||||||
message, f"❌ 还没有将 __{group_name}__ 加入进自动回复Emoji群组黑名单哦~")
|
|
||||||
|
|
||||||
else:
|
|
||||||
return await message.edit(f"{lang('error_prefix')}{lang('arg_error')}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=False, incoming=True, ignore_edited=True)
|
|
||||||
async def AutoSendReactions(message: Message):
|
|
||||||
from_user = ''
|
|
||||||
try:
|
|
||||||
# 判断是否启用了本插件
|
|
||||||
if not sqlite.get("AutoSendReactions.Enable"):
|
|
||||||
return
|
|
||||||
if 'GROUP' not in str(message.chat.type):
|
|
||||||
return
|
|
||||||
# 判断是否在黑名单中
|
|
||||||
if sqlite.get(f"AutoSendReactionsBlock.{message.chat.id}"):
|
|
||||||
return
|
|
||||||
if not message.from_user:
|
|
||||||
# 过滤匿名管理员
|
|
||||||
return
|
|
||||||
|
|
||||||
from_user = message.from_user
|
|
||||||
if not sqlite.get(f"AutoSendReactions.{from_user.id}"):
|
|
||||||
return
|
|
||||||
# 判断群组是否启用了表情回应功能
|
|
||||||
group_info = await bot.get_chat(chat_id=message.chat.id)
|
|
||||||
if not group_info.available_reactions:
|
|
||||||
return
|
|
||||||
|
|
||||||
# 发送表情
|
|
||||||
emoji = sqlite.get(f"AutoSendReactions.{from_user.id}").split('|')[0]
|
|
||||||
user_name = (
|
|
||||||
f'{from_user.first_name} {from_user.last_name}'
|
|
||||||
if from_user.last_name
|
|
||||||
else from_user.first_name
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
await bot.send_reaction(message.chat.id, message.id, emoji)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
errorMsg = f"❌ 自动回复Emoji失败({user_name} {emoji})> {e}"
|
|
||||||
await log(errorMsg)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# 打印日志
|
|
||||||
# text = message.text.markdown
|
|
||||||
# await log(f"AutoSendReactions 监控到来自 {user_name} 的消息:{str(text)}")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
errorMsg = f"❌ 第{e.__traceback__.tb_lineno}行:{e}"
|
|
||||||
await log(errorMsg)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
## ⬆️ 不懂勿动 ⬆️
|
|
@ -3,13 +3,15 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
def update_des():
|
def update_des():
|
||||||
with open("list.json", "r", encoding="utf8") as f:
|
list_json_start = ["", "alpha/"]
|
||||||
|
for start in list_json_start:
|
||||||
|
with open(f"{start}list.json", "r", encoding="utf8") as f:
|
||||||
list_json = json.load(f)
|
list_json = json.load(f)
|
||||||
for plugin in list_json["list"]:
|
for plugin in list_json["list"]:
|
||||||
if os.path.exists(f"{plugin['name']}{os.sep}DES.md"):
|
if os.path.exists(f"{start}{plugin['name']}{os.sep}DES.md"):
|
||||||
with open(f"{plugin['name']}{os.sep}DES.md", "r", encoding="utf8") as f:
|
with open(f"{start}{plugin['name']}{os.sep}DES.md", "r", encoding="utf8") as f:
|
||||||
plugin["des"] = f.read().strip()
|
plugin["des"] = f.read().strip()
|
||||||
with open("list.json", "w", encoding="utf8") as f:
|
with open(f"{start}list.json", "w", encoding="utf8") as f:
|
||||||
json.dump(list_json, f, ensure_ascii=False, indent=4)
|
json.dump(list_json, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,24 +7,31 @@ from update_des import update_des
|
|||||||
|
|
||||||
main = get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").json()
|
main = get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").json()
|
||||||
plugins = []
|
plugins = []
|
||||||
|
alpha_plugins = []
|
||||||
|
list_json_start = ["", "alpha/"]
|
||||||
for file in main["files"]:
|
for file in main["files"]:
|
||||||
if file["filename"] == "list.json":
|
if "list.json" in file["filename"]:
|
||||||
print(main['sha'] + " no need!")
|
print(main['sha'] + " no need!")
|
||||||
exit()
|
exit()
|
||||||
if "/main.py" in file["filename"]:
|
if "/main.py" in file["filename"]:
|
||||||
|
if file["filename"].startswith("alpha"):
|
||||||
|
alpha_plugins.append(file["filename"].split("/")[1])
|
||||||
|
else:
|
||||||
plugins.append(file["filename"].split("/")[0])
|
plugins.append(file["filename"].split("/")[0])
|
||||||
delete = bool(main['commit']['message'].startswith("Delete"))
|
delete = bool(main['commit']['message'].startswith("Delete"))
|
||||||
|
|
||||||
with open("list.json", "r", encoding="utf8") as f:
|
|
||||||
|
for idx, plugins_ in enumerate([plugins, alpha_plugins]):
|
||||||
|
with open(f"{list_json_start[idx]}list.json", "r", encoding="utf8") as f:
|
||||||
list_json = json.load(f)
|
list_json = json.load(f)
|
||||||
for plugin in plugins:
|
for plugin in plugins_:
|
||||||
exist = False
|
exist = False
|
||||||
for plug_dict in list_json["list"]:
|
for plug_dict in list_json["list"]:
|
||||||
if plug_dict["name"] == plugin:
|
if plug_dict["name"] == plugin:
|
||||||
exist = True
|
exist = True
|
||||||
old_version = decimal.Decimal(plug_dict["version"])
|
old_version = decimal.Decimal(plug_dict["version"])
|
||||||
plug_dict["version"] = old_version + decimal.Decimal("0.01")
|
plug_dict["version"] = old_version + decimal.Decimal("0.01")
|
||||||
plug_dict["size"] = f"{os.path.getsize(f'{plugin}{os.sep}main.py') / 1000} kb"
|
plug_dict["size"] = f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb"
|
||||||
if delete:
|
if delete:
|
||||||
list_json["list"].remove(plug_dict)
|
list_json["list"].remove(plug_dict)
|
||||||
break
|
break
|
||||||
@ -36,13 +43,13 @@ for plugin in plugins:
|
|||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": main['commit']['author']['name'],
|
"maintainer": main['commit']['author']['name'],
|
||||||
"size": f"{os.path.getsize(f'{plugin}{os.sep}main.py') / 1000} kb",
|
"size": f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb",
|
||||||
"supported": True,
|
"supported": True,
|
||||||
"des_short": short_des,
|
"des_short": short_des,
|
||||||
"des": "",
|
"des": "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
with open("list.json", "w", encoding="utf8") as f:
|
with open(f"{list_json_start[idx]}list.json", "w", encoding="utf8") as f:
|
||||||
json.dump(list_json, f, ensure_ascii=False, indent=4)
|
json.dump(list_json, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
update_des()
|
update_des()
|
||||||
|
Loading…
Reference in New Issue
Block a user