自定义开播通知群

This commit is contained in:
2025-08-27 14:56:01 +08:00
parent b0f226fcef
commit 09a2d65a34
3 changed files with 24 additions and 4 deletions

View File

@@ -11,6 +11,11 @@ import re
path = "logs"
room_id_re = re.compile(rf"{path}/(\d+).jsonl$")
notify_qq_group = {
"12571885": ["831867573", "138981147"],
"147482": ["175545447"],
}
class Room:
position = 0
@@ -18,7 +23,7 @@ class Room:
state = 0
state_changed = False
def __init__(self, room_id) -> None:
def __init__(self, room_id: str) -> None:
self.room_id = room_id
self.db_room = db.get_room(room_id)
@@ -133,6 +138,9 @@ class MyHandler(FileSystemEventHandler):
])
requests.post("http://turntf:18846/notify", json={"msg": msg})
for notify_group in notify_qq_group.get(room.room_id, []):
seng_qq_group_msg(notify_group, msg)
elif room.state == 2:
msg = "\n".join([
f"{room.db_room.liver_name} 下锅了!",
@@ -140,6 +148,16 @@ class MyHandler(FileSystemEventHandler):
])
requests.post("http://turntf:18846/notify", json={"msg": msg})
for notify_group in notify_qq_group.get(room.room_id, []):
seng_qq_group_msg(notify_group, msg)
def seng_qq_group_msg(group_id: str, msg: str):
requests.post("http://napcat:3000/send_group_msg", json={
"group_id": group_id,
"message": msg
})
def main():
for f in os.listdir(path):