添加导入导出数据功能 (#127)

This commit is contained in:
c3b2a 2021-02-12 16:38:22 +08:00 committed by GitHub
parent 5a860c04c3
commit 23ad62b495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 5 deletions

View File

@ -783,6 +783,37 @@ async def funcset(context):
pass
@listener(outgoing=True, command="keyworddata",
description="设置规则数据",
parameters="dump / load")
async def setdata(context):
try:
chat_id = context.chat_id
params = context.parameter
if params[0] == "dump":
data = redis.get(f"keyword.{chat_id}.{params[1]}")
if not data:
await context.edit("无规则数据")
await del_msg(context, 5)
return
data = str(data, "ascii")
await context.edit(data)
return
elif params[0] == "load":
redis.set(f"keyword.{chat_id}.{params[1]}", params[2])
await context.edit("设置成功")
await del_msg(context, 5)
return
else:
await context.edit("参数错误")
await del_msg(context, 5)
return
except:
await context.edit("运行错误")
await del_msg(context, 5)
return
@listener(incoming=True, ignore_edited=False)
async def auto_reply(context):
if not redis_status():
@ -846,4 +877,4 @@ async def auto_reply(context):
count += 1
await send_reply(chat_id, k, "regex", parse_multi(v), context)
except:
pass
pass

View File

@ -362,13 +362,13 @@
},
{
"name": "keyword",
"version": "2.54",
"version": "2.55",
"section": "chat",
"maintainer": "c3b2a,xtaodada",
"size": "36.5 kb",
"size": "36.7 kb",
"supported": true,
"des-short": "群组关键词自动回复插件",
"des": "命令: keyword, replyset, funcset。"
"des-short": "关键词自动回复插件",
"des": "命令: keyword, keyworddata, replyset, funcset。"
},
{
"name": "msgst",