-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (26 loc) · 851 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from time import sleep
from os import getenv
from playsound import playsound
def follow(file):
file.seek(0, 2)
while True:
line_ = file.readline()
if not line_:
sleep(0.1)
continue
yield line_
if __name__ == "__main__":
try:
logfile = open(getenv("APPDATA")+"/.minecraft/logs/latest.log", "r")
log_lines = follow(logfile)
for line in log_lines:
if '[CHAT]' in line:
newline = line.split('[CHAT]')[1]
if '[СПм]' in newline:
message_time = line.split('[')[1].split(']')[0]
print(f"{message_time}{newline}")
if 'детектив' in newline.lower():
playsound("notify.mp3")
except Exception as e:
print(e)
sleep(5)