mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-22 06:17:54 +00:00
🎨 改进代码
1. 取消了 daily_material 模块的提示消息撤回 2. 为 daily_material 添加命令日志 3. 删除无用代码
This commit is contained in:
parent
b477dc7648
commit
a7b28b0688
@ -140,12 +140,13 @@ class DailyMaterial(Plugin, BasePlugin):
|
|||||||
time = now.strftime("%m-%d %H:%M") + " 星期" + WEEK_MAP[weekday]
|
time = now.strftime("%m-%d %H:%M") + " 星期" + WEEK_MAP[weekday]
|
||||||
full = args and args[-1] == 'full'
|
full = args and args[-1] == 'full'
|
||||||
|
|
||||||
|
logger.info(f"用户 {user.full_name}[{user.id}] 每日素材命令请求 || 参数 weekday={weekday} full={full}")
|
||||||
|
|
||||||
if weekday == 6:
|
if weekday == 6:
|
||||||
notice = await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
("今天" if title == '今日' else '这天') + "是星期天, <b>全部素材都可以</b>刷哦~",
|
("今天" if title == '今日' else '这天') + "是星期天, <b>全部素材都可以</b>刷哦~",
|
||||||
parse_mode=ParseMode.HTML
|
parse_mode=ParseMode.HTML
|
||||||
)
|
)
|
||||||
self._add_delete_message_job(context, notice.chat_id, notice.message_id, 5)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.locks[0].locked():
|
if self.locks[0].locked():
|
||||||
@ -154,8 +155,7 @@ class DailyMaterial(Plugin, BasePlugin):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self.locks[1].locked():
|
if self.locks[1].locked():
|
||||||
notice = await update.message.reply_text("派蒙正在搬运每日素材的图标,以后再来探索吧~")
|
await update.message.reply_text("派蒙正在搬运每日素材的图标,以后再来探索吧~")
|
||||||
self._add_delete_message_job(context, notice.chat_id, notice.message_id, 5)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
notice = await update.message.reply_text("派蒙可能需要找找图标素材,还请耐心等待哦~")
|
notice = await update.message.reply_text("派蒙可能需要找找图标素材,还请耐心等待哦~")
|
||||||
@ -278,6 +278,7 @@ class DailyMaterial(Plugin, BasePlugin):
|
|||||||
result[key][day][1].append(id_)
|
result[key][day][1].append(id_)
|
||||||
for stage, schedules in result.items():
|
for stage, schedules in result.items():
|
||||||
for day, _ in enumerate(schedules):
|
for day, _ in enumerate(schedules):
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
result[stage][day][1] = list(set(result[stage][day][1]))
|
result[stage][day][1] = list(set(result[stage][day][1]))
|
||||||
async with async_open(DATA_FILE_PATH, 'w', encoding='utf-8') as file:
|
async with async_open(DATA_FILE_PATH, 'w', encoding='utf-8') as file:
|
||||||
await file.write(json.dumps(result)) # pylint: disable=PY-W0079
|
await file.write(json.dumps(result)) # pylint: disable=PY-W0079
|
||||||
|
@ -150,24 +150,3 @@ def mkdir(path: Path) -> Path:
|
|||||||
path_list.pop().mkdir(exist_ok=True)
|
path_list.pop().mkdir(exist_ok=True)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
class Event:
|
|
||||||
"""一个线程安装的事件对象"""
|
|
||||||
_event: asyncio.Event = asyncio.Event()
|
|
||||||
_lock = RLock()
|
|
||||||
|
|
||||||
async def wait(self) -> bool:
|
|
||||||
return await self._event.wait()
|
|
||||||
|
|
||||||
def set(self):
|
|
||||||
with self._lock:
|
|
||||||
self._event.set()
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
with self._lock:
|
|
||||||
self._event.clear()
|
|
||||||
|
|
||||||
def is_set(self) -> bool:
|
|
||||||
with self._lock:
|
|
||||||
return self._event.is_set()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user