Я пытаюсь создать программу, которая бы уведомляла меня, когда происходит определенное событие (присоединение к серверу Minecraft), используя модуль win10toast. Проблема в том, что примерно половина времени (и в разных средах) код выдает эту ошибку: pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')
. Я не могу найти ответ на это нигде. Вот код, если это помогает:
import win10toast
from datetime import datetime, timedelta
from notify_run import Notify
notify = Notify()
toaster = win10toast.ToastNotifier()
def ping(message, i = 10, toast = True):
message = "[" + str(datetime.now().time()) + "] " + message
print(message)
if toast == True:
try:
toaster.show_toast('2B2T bot', message, duration=i)
except:
print('error')
notify.send(message)
disconnect = True
important = 101
pos = 10000
while True:
sleep(2)
with open("C:\\Users\\Penguin\\AppData\\Roaming\\.minecraft\\logs\\latest.log", "r") as file:
last_line = file.readlines()[-1]
if "[main/INFO]: [CHAT] Position in queue: " in last_line:
if (disconnect == True):
ping("You are now connected")
disconnect = False
if pos != int(last_line[50:]):
ping(str(pos), 10, False)
pos = int(last_line[50:])
if pos < 100 and important > 100:
important = pos
ping("You are below 100 in the queue!")
elif pos < 10 and important > 10:
important = pos
ping("YOU ARE BELOW 10 IN THE QUEUE", 50)
elif pos <= 2 and important > 2:
important = pos
ping("YOU ARE ABOUT TO JOIN PLEASE CONNECT", 50)
ping("YOU ARE ABOUT TO JOIN PLEASE CONNECT", 50)
ping("YOU ARE ABOUT TO JOIN PLEASE CONNECT", 50)
elif "[main/INFO]: Connecting to 2b2t.org, 25565" in last_line and disconnect == False:
disconnect = True
ping("You are no longer connected to the server", 50)
important = 101
elif "[main/INFO]: [CHAT] [SERVER] Server restarting in" in last_line:
ping("THE SERVER IS ABOUT TO RESTART", 30)