新增插件:yyr 把普通的话转换成抽象话 (#176)

* 新增插件:yyr 把普通的话转换成抽象话

Co-authored-by: Xtao_dada <xtao@xtaolink.cn>
This commit is contained in:
F2DRD 2021-07-28 21:51:45 +08:00 committed by GitHub
parent fbe23feb4b
commit 707c8114f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -659,6 +659,16 @@
"supported": true, "supported": true,
"des-short": "删除烦人的消息", "des-short": "删除烦人的消息",
"des": "删除最近 200 条消息中包含指定关键字的消息。" "des": "删除最近 200 条消息中包含指定关键字的消息。"
},
{
"name": "yyr",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada、kld",
"size": "0.9 kb",
"supported": true,
"des-short": "抽象话转换",
"des": "把普通的话转换成抽象话"
} }
] ]
} }

31
yyr.py Normal file
View File

@ -0,0 +1,31 @@
import json, requests
from pagermaid.listener import listener
from pagermaid.utils import alias_command
@listener(is_plugin=True, outgoing=True, command=alias_command("yyr"),
description="我们都是孙笑川",
parameters="<字符串>")
async def yyr(context):
text = context.arguments
if not text:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
try:
req_data = requests.get("https://github.com/gaowanliang/NMSL/raw/master/src/data/emoji.json").text
except Exception as e:
await context.edit("出错了呜呜呜 ~ 无法获取词库。")
return
try:
req_data = json.loads(req_data)
except Exception as e:
await context.edit("出错了呜呜呜 ~ 解析JSON时发生了错误。")
return
result = text
for key in sorted(req_data, key=len, reverse=True):
result = result.replace(key, req_data[key])
await context.edit(result)