update
This commit is contained in:
parent
46ef3d4d0a
commit
679e73bfb2
@ -55,20 +55,22 @@ class MyHandler(FileSystemEventHandler):
|
|||||||
|
|
||||||
room: Room = get_room(event.src_path)
|
room: Room = get_room(event.src_path)
|
||||||
|
|
||||||
with open(event.src_path, "r", encoding="utf-8") as f:
|
try:
|
||||||
|
with open(event.src_path, "r", encoding="utf-8") as f:
|
||||||
|
if room.position > os.path.getsize(event.src_path):
|
||||||
|
room.reset()
|
||||||
|
f.seek(room.position)
|
||||||
|
|
||||||
if room.position > os.path.getsize(event.src_path):
|
room.position = os.path.getsize(event.src_path)
|
||||||
room.reset()
|
|
||||||
f.seek(room.position)
|
|
||||||
|
|
||||||
room.position = os.path.getsize(event.src_path)
|
for line in f:
|
||||||
|
try:
|
||||||
for line in f:
|
data = json.loads(line)
|
||||||
try:
|
except json.decoder.JSONDecodeError:
|
||||||
data = json.loads(line)
|
continue
|
||||||
except json.decoder.JSONDecodeError:
|
self._handle_data(room, data)
|
||||||
continue
|
except UnicodeDecodeError:
|
||||||
self._handle_data(room, data)
|
pass
|
||||||
|
|
||||||
self._check_room_state_change(room)
|
self._check_room_state_change(room)
|
||||||
|
|
||||||
@ -122,16 +124,16 @@ class MyHandler(FileSystemEventHandler):
|
|||||||
room.state_changed = False
|
room.state_changed = False
|
||||||
|
|
||||||
if room.state == 1:
|
if room.state == 1:
|
||||||
msg = f"{room.db_room.liver_name} 开锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
msg = f"{
|
||||||
|
room.db_room.liver_name} 开锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
||||||
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
||||||
|
|
||||||
elif room.state == 2:
|
elif room.state == 2:
|
||||||
msg = f"{room.db_room.liver_name} 下锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
msg = f"{
|
||||||
|
room.db_room.liver_name} 下锅了!\nhttps://live.bilibili.com/{room.room_id}"
|
||||||
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
requests.post("http://turntf:18846/notify", json={"msg": msg})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
f = path+"/"+str(f)
|
f = path+"/"+str(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user