update
This commit is contained in:
parent
61e2cc76fd
commit
e74ff10238
@ -84,13 +84,16 @@ class MyHandler(FileSystemEventHandler):
|
||||
room: Room = get_room(event.src_path)
|
||||
room.position = os.path.getsize(event.src_path)
|
||||
|
||||
with open(event.src_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
try:
|
||||
data = json.loads(line)
|
||||
except json.decoder.JSONDecodeError:
|
||||
continue
|
||||
self._handle_data(data)
|
||||
try:
|
||||
with open(event.src_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
try:
|
||||
data = json.loads(line)
|
||||
except json.decoder.JSONDecodeError:
|
||||
continue
|
||||
self._handle_data(data)
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
self._check_room_state_change(room)
|
||||
|
||||
@ -124,11 +127,17 @@ class MyHandler(FileSystemEventHandler):
|
||||
room.state_changed = False
|
||||
|
||||
if room.state == 1:
|
||||
msg = f"{room.db_room.liver_name} 开锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
||||
msg = "\n".join([
|
||||
f"{room.db_room.liver_name} 开锅了!",
|
||||
f"https://live.bilibili.com/{room.room_id}"
|
||||
])
|
||||
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
||||
|
||||
elif room.state == 2:
|
||||
msg = f"{room.db_room.liver_name} 下锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
||||
msg = "\n".join([
|
||||
f"{room.db_room.liver_name} 下锅了!",
|
||||
f"https://live.bilibili.com/{room.room_id}"
|
||||
])
|
||||
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user