Compare commits

...

2 Commits

Author SHA1 Message Date
990a622cf6 添加一些日志用于调试 Notify 功能
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-10-13 11:48:22 +08:00
6144563d4d 添加 giftool 倒放选项 2025-10-13 11:34:06 +08:00
3 changed files with 27 additions and 11 deletions

View File

@ -46,7 +46,7 @@
- 若原始帧数 ≤ 指定帧数,则保留全部帧。 - 若原始帧数 ≤ 指定帧数,则保留全部帧。
--s <速度>(可选) --s <速度>(可选)
- 调整 gif 图的速度 - 调整 gif 图的速度。若为负数,则代表倒放
使用方式 使用方式
1. 发送指令前,请确保: 1. 发送指令前,请确保:

View File

@ -71,8 +71,11 @@ async def _(
raise BotExceptionMessage("错误:出点时间小于入点") raise BotExceptionMessage("错误:出点时间小于入点")
if frame_count is not None and frame_count <= 0: if frame_count is not None and frame_count <= 0:
raise BotExceptionMessage("错误:帧数量应该大于 0") raise BotExceptionMessage("错误:帧数量应该大于 0")
if speed_factor <= 0: if speed_factor == 0:
raise BotExceptionMessage("错误:--speed 必须大于 0") raise BotExceptionMessage("错误:速度不能为 0")
is_rev = speed_factor < 0
speed_factor = abs(speed_factor)
if not getattr(image, "is_animated", False): if not getattr(image, "is_animated", False):
raise BotExceptionMessage("错误输入的不是动图GIF") raise BotExceptionMessage("错误输入的不是动图GIF")
@ -185,6 +188,10 @@ async def _(
if transparency_flag: if transparency_flag:
tf['transparency'] = 0 tf['transparency'] = 0
if is_rev:
rframes = rframes[::-1]
rdur = rdur[::-1]
if rframes: if rframes:
rframes[0].save( rframes[0].save(
output_img, output_img,

View File

@ -107,11 +107,16 @@ async def notify_now(notify: Notify):
return True return True
async def create_notify_task(notify: Notify, fail2remove: bool = True): def create_notify_task(notify: Notify, fail2remove: bool = True):
async def mission(): async def mission():
begin_time = datetime.datetime.now() begin_time = datetime.datetime.now()
if begin_time < notify.notify_time: if begin_time < notify.notify_time:
await asyncio.sleep((notify.notify_time - begin_time).total_seconds()) await asyncio.sleep((notify.notify_time - begin_time).total_seconds())
else:
logger.warning(
f"期望在 {notify.notify_time} 在平台 {notify.platform} {notify.target_env}"
f"{notify.target} 的代办通知 {notify.notify_msg} 已经超时,将会直接通知!"
)
res = await notify_now(notify) res = await notify_now(notify)
if fail2remove or res: if fail2remove or res:
await DATA_FILE_LOCK.acquire() await DATA_FILE_LOCK.acquire()
@ -204,16 +209,20 @@ async def _():
return return
NOTIFIED_FLAG["task_added"] = True NOTIFIED_FLAG["task_added"] = True
logger.info("第一次探测到 Bot 连接,等待 10 秒后开始通知")
await asyncio.sleep(10) await asyncio.sleep(10)
await DATA_FILE_LOCK.acquire() await DATA_FILE_LOCK.acquire()
tasks = []
tasks: set[asyncio.Task[Any]] = set()
cfg = load_notify_config() cfg = load_notify_config()
if cfg.version == 1: if cfg.version == 1:
cfg.version = 2 cfg.version = 2
else: else:
for notify in cfg.notifies: for notify in cfg.notifies:
tasks.append(create_notify_task(notify, fail2remove=False)) task = create_notify_task(notify, fail2remove=False)
tasks.add(task)
task.add_done_callback(lambda self: tasks.remove(self))
DATA_FILE_LOCK.release() DATA_FILE_LOCK.release()
await asyncio.gather(*tasks) await asyncio.gather(*tasks)