keyword 更新,函数改为异步 (#115)

main函数需使用async,但同时也可以在里面控制bot
This commit is contained in:
c3b2a 2021-02-06 13:47:14 +08:00 committed by GitHub
parent d877040d99
commit fe1782dab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -150,7 +150,8 @@ async def send_reply(chat_id, reply_msg, context):
while re.search(catch_pattern, re_msg) and count < 20: while re.search(catch_pattern, re_msg) and count < 20:
func_name = re.search(catch_pattern, re_msg).group("str") func_name = re.search(catch_pattern, re_msg).group("str")
try: try:
func_data = import_module(f"plugins.keyword_func.{func_name}").main(context) module = import_module(f"plugins.keyword_func.{func_name}")
func_data = await module.main(context)
except: except:
func_data = "[RE]" func_data = "[RE]"
re_msg = re_msg.replace("${func_%s}" % func_name, str(func_data)) re_msg = re_msg.replace("${func_%s}" % func_name, str(func_data))

View File

@ -362,7 +362,7 @@
}, },
{ {
"name": "keyword", "name": "keyword",
"version": "2.2", "version": "2.21",
"section": "chat", "section": "chat",
"maintainer": "c3b2a", "maintainer": "c3b2a",
"size": "24.5 kb", "size": "24.5 kb",