增加定时精准度 (#101)

* Update msgst.py

* Update list.json
This commit is contained in:
c3b2a 2021-01-23 07:55:51 +08:00 committed by GitHub
parent 9fb2606fd9
commit 0f043a40ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -372,12 +372,12 @@
},
{
"name": "msgst",
"version": "1.0",
"version": "1.1",
"section": "chat",
"maintainer": "c3b2a",
"size": "3.0 kb",
"size": "3.1 kb",
"supported": true,
"des-short": "消息每天定时发送",
"des-short": "每天定时发送消息",
"des": "命令: msgst, msgset。"
}
]

View File

@ -1,4 +1,4 @@
import asyncio
import time, asyncio
from pagermaid import bot, redis, redis_status
from pagermaid.listener import listener
@ -24,7 +24,7 @@ async def del_msg(context, t_lim):
@listener(is_plugin=True, outgoing=True, command="msgst",
description="消息每天定时发送",
parameters="new <time> <text>` 或 `del <msg_id>` 或 `list")
parameters="new 时:分:秒 消息` 或 `del <msg_id>` 或 `list")
async def process(context):
params = []
for p in context.parameter:
@ -78,4 +78,6 @@ async def sendmsg(context):
if parse[0] == "send_msg":
async with bot.conversation(bot_data[1]) as conversation:
await bot.send_read_acknowledge(conversation.chat_id)
s_time = int(time.time() + 1) - time.time()
await asyncio.sleep(s_time)
await bot.send_message(int(parse[1]), "|".join(parse[2:]))