View difference between Paste ID: dWXKpMnM and E7UtHiKx
SHOW: | | - or go back to the newest paste.
1
import requests
2
from time import sleep
3
4-
bot_id = "" #Your Telegram Bot id
4+
bot_id = "564119448:AAGamyjF_tLNBwS1ZG9wYuFjuV3t0UDWxpY" #Your Telegram Bot id
5-
chat_id = "" #Your Telegram account or group chat id
5+
chat_id = "559428290" #Your Telegram account or group chat id
6
time_need = 960 #15 min
7
message_for_time = "Logs have not changed in the last " + str(time_need/60) + " minutes"
8
9
last_line = ""
10
r = 0
11
12
filter_1 = "Game is closed or not responding for more than 2 minutes. Restarting D3..." #filter for checking
13
filter_2 = "Running Step : clearWhimsydale" #filter for checking
14
filter_3 = "Running Step : theVault" #filter for checking
15
message_filter_1 = "ROS Bot crash" #message to Telegram if found matches with filter_1
16
message_filter_2 = "Whimsydale" #message to Telegram if found matches with filter_2
17
message_filter_3 = "The Vault" #message to Telegram if found matches with filter_3
18
19
number_of_filters = 0
20
filters_accept = False
21
22
while filters_accept == False:
23
    try:
24
        number_of_filters = int(input("""Input number of filter settings:
25
All filters - 1
26
Only filter_1 - 2
27
filter_1 and filter_2 - 3
28
filter_1 and filter_3 - 4\n"""))
29
        if 0 < number_of_filters < 5:
30
            print("Filters accept")
31
            filters_accept = True
32
        else:
33
            print("Input number from list")
34
    except:
35
        print("Input number from list")
36
print("Start reading logs.txt")
37
line_repeat = []
38
39
def checking(Filter, message):
40
    global line_repeat
41
    if Filter in line[-i] and not any(c in line[-i] for c in line_repeat):
42
            get = requests.get("https://api.telegram.org/bot"+ bot_id +"/sendMessage?chat_id="+ chat_id +"&text=" + message)
43
            line_repeat.append(line[-i])
44
            print(line[-i])
45
            
46
47
while True:
48
    i=0
49
    
50
    try:
51
        f = open('logs.txt','r') #You need to bring this script to folder with logs.txt
52-
        #f = open('//Computer name/Users/Username/Documents/RoS-BoT/Logs/logs.txt','r') #This if you want to launch anywhere
52+
        #f = open('//C:/Users/Pro/Documents/RoS-BoT/Logs/logs.txt','r') #This if you want to launch anywhere
53
    except:
54
        print("Cannot access to file")
55
        sleep(20)
56
        continue
57
        
58
    line = f.readlines()
59
    while i<20:
60
        i+=1
61
        if i == 1:
62
            if last_line == line[-i]:
63
                r +=1
64
            else:
65
                r = 0
66
            if r == time_need/20:
67
                print(last_line)
68
                get = requests.get("https://api.telegram.org/bot"+ bot_id +"/sendMessage?chat_id="+ chat_id +"&text=" + message_for_time)
69
            last_line = line[-i]
70
        if number_of_filters == 1:
71
            checking(filter_1, message_filter_1)
72
            checking(filter_2, message_filter_2)
73
            checking(filter_3, message_filter_3)
74
        if number_of_filters == 2:
75
            checking(filter_1, message_filter_1)
76
        if number_of_filters == 3:
77
            checking(filter_1, message_filter_1)
78
            checking(filter_2, message_filter_2)
79
        if number_of_filters == 4:
80
            checking(filter_1, message_filter_1)
81
            checking(filter_3, message_filter_3)
82
        
83
            
84
    f.close()
85
    sleep(20)