-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDeviceChecker.py
More file actions
185 lines (147 loc) · 7.16 KB
/
DeviceChecker.py
File metadata and controls
185 lines (147 loc) · 7.16 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import time
import mysql.connector
import datetime
import config
# MADE BY ATAKU
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
#DO NOT TOUCH THIS FILE ANYMORE
# Work with Python 3.6
# If you get an aioHttp error try downgrading discord.py "pip3.6 install 'discord.py<1.0"
import discord
i1 = [] # dont mind this :3
TOKEN = config.TOKEN
YourDiscordID = config.YourDiscordID
editedmsg = ""
Phone_uuids = config.Phone_uuids
# Add phone uuids like: ["phoneuuid1", "phoneuuid2"] etc etc
devicecount = 0
for i in Phone_uuids:
devicecount = devicecount+1
i1.append("")
# Add as many phone ids as you want :) - Ataku
client = discord.Client()
def initial_msg(deviceids):
initialmsg = ""
fmsg = []
deviceids_length = len(deviceids)
for i in range(deviceids_length):
fmsg.append(["\n", deviceids[i], " About to check device..."])
initialmsg += (fmsg[i][0] + fmsg[i][1] + fmsg[i][2])
return fmsg, initialmsg
def errormsg(numberofdevices):
d_broke = []
d_error_message = []
numberofdevices_length = len(numberofdevices)
for i in range(numberofdevices_length):
d_broke.append("0")
d_error_message.append("1")
return d_broke, d_error_message
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
if message.content.startswith('!start'):
print(message.author.id)
if message.author.id == YourDiscordID:
sock = 1
print("Bot can see your message!")
print("Bot can see your message!")
print("Bot can see your message!")
BOT_MSG, initialmsg = initial_msg(Phone_uuids)
fmsg = await client.send_message(message.channel, initialmsg)
d_broke, d_error_message = errormsg(Phone_uuids)
while sock == 1:
time.sleep(5)
try:
cnx = mysql.connector.connect(user=config.user, password=config.password,
host=config.host, port=config.port,
database=config.database)
cursor = cnx.cursor()
cursor.execute("SELECT uuid, last_seen,instance_name FROM "+config.database+".device")
except:
time.sleep(10)
print("MYSQL CONNECTION ISSUE")
print("MYSQL CONNECTION ISSUE")
print("MYSQL CONNECTION ISSUE")
print("MYSQL CONNECTION ISSUE")
print("MYSQL CONNECTION ISSUE")
cnx = mysql.connector.connect(user=config.user, password=config.password,
host=config.host, port=config.port,
database=config.database)
cursor = cnx.cursor()
cursor.execute("SELECT uuid, last_seen,instance_name FROM " + config.database + ".device")
print("MYSQL CONNECTION FIXED")
# DO NOT TOUCH BELOW
# Literally so delicate you could break everything :(
for (uuid, last_seen, instance_name) in cursor:
editedmsg = ""
print("{}, {} ".format(
uuid, last_seen, instance_name))
times = time.time()
int(times)
print("THE CURRENT TIME IS: " + str(times))
int(times)
Phone_uuids_length = len(Phone_uuids)
for i in range(Phone_uuids_length):
if uuid == Phone_uuids[i]:
i1[i] = instance_name
if last_seen > (times - 12000) or last_seen > (times - times):
BOT_MSG[i][2] = ': :no_mobile_phones:'
if d_broke[i] == "1" and d_error_message[i] == "0":
await client.send_message(message.author, str(
BOT_MSG[i][1]) + " is Having Trouble!!")
d_error_message[i] = "1"
d_broke[i] = "1"
if last_seen > (times - 400):
BOT_MSG[i][2] = ": :warning:"
d_broke[i] = "0"
if last_seen > (times - 30):
BOT_MSG[i][2] = ": :white_check_mark:"
d_broke[i] = "0"
d_error_message[i] = "0"
print("Device is up" + "\n\n\n\n")
cursor.close()
cnx.close()
datetime.datetime.now()
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
for i in range(Phone_uuids_length):
editedmsg += (
BOT_MSG[i][0] + str(BOT_MSG[i][1]) + BOT_MSG[i][2] + '(' + i1[i] + ')')
try:
await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
except:
time.sleep(5)
try:
await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
except:
time.sleep(20)
try:
await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
except:
time.sleep(60)
print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)