Skip to content

Commit

Permalink
deprecated: send waifu graph at 4:00
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Oct 15, 2023
1 parent 9655fa0 commit f4fbebe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
22 changes: 4 additions & 18 deletions kmua/callbacks/jobs.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
import asyncio

from telegram.ext import ContextTypes

from kmua.logger import logger
import kmua.dao as dao
from .waifu import send_waifu_graph


async def refresh_waifu_data(context: ContextTypes.DEFAULT_TYPE):
logger.debug("Start refreshing waifu data")
try:
context.bot_data["refeshing_waifu_data"] = True
await asyncio.gather(
*(send_waifu_graph(chat, context) for chat in dao.get_all_chats())
)
except Exception as err:
logger.error(
f"{err.__class__.__name__}: {err} happend when performing waifu graph tasks"
)
raise err
finally:
await asyncio.sleep(3)
await dao.refresh_all_waifu_data()
logger.success("数据已刷新: waifu_data")
context.bot_data["refeshing_waifu_data"] = False
context.bot_data["refeshing_waifu_data"] = True
await dao.refresh_all_waifu_data()
logger.success("数据已刷新: waifu_data")
context.bot_data["refeshing_waifu_data"] = False


async def delete_message(context: ContextTypes.DEFAULT_TYPE):
Expand Down
1 change: 1 addition & 0 deletions kmua/callbacks/waifu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def send_waifu_graph(
"本群今日没有人抽过老婆哦",
reply_to_message_id=msg_id,
)
logger.debug(f"No user participated waifu in {chat.title}<{chat.id}>")
return
user_info = {
user.id: {
Expand Down

0 comments on commit f4fbebe

Please sign in to comment.