Advertisement
Guest User

Untitled

a guest
Dec 26th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.02 KB | None | 0 0
  1. import time
  2. import mysql.connector
  3. import datetime
  4. import config
  5. # MADE BY ATAKU
  6.  
  7. #DO NOT TOUCH THIS FILE ANYMORE
  8. #DO NOT TOUCH THIS FILE ANYMORE
  9. #DO NOT TOUCH THIS FILE ANYMORE
  10. #DO NOT TOUCH THIS FILE ANYMORE
  11. #DO NOT TOUCH THIS FILE ANYMORE
  12. #DO NOT TOUCH THIS FILE ANYMORE
  13. #DO NOT TOUCH THIS FILE ANYMORE
  14. #DO NOT TOUCH THIS FILE ANYMORE
  15. #DO NOT TOUCH THIS FILE ANYMORE
  16. #DO NOT TOUCH THIS FILE ANYMORE
  17.  
  18. # Work with Python 3.6
  19. import discord
  20. i1 = [] # dont mind this :3
  21. TOKEN = config.TOKEN
  22.  
  23. YourDiscordID = config.YourDiscordID
  24.  
  25. editedmsg = ""
  26. Phone_uuids = config.Phone_uuids
  27. # Add phone uuids like: ["phoneuuid1", "phoneuuid2"] etc etc
  28. devicecount = 0
  29. for i in Phone_uuids:
  30. devicecount = devicecount+1
  31. i1.append("")
  32.  
  33. # Add as many phone ids as you want :) - Ataku
  34.  
  35. client = discord.Client()
  36.  
  37.  
  38.  
  39. def initial_msg(deviceids):
  40. initialmsg = ""
  41. fmsg = []
  42. deviceids_length = len(deviceids)
  43. for i in range(deviceids_length):
  44. fmsg.append(["\nDevice ", i, " About to check device..."])
  45. initialmsg += (fmsg[i][0]+str(fmsg[i][1]+1)+fmsg[i][2])
  46.  
  47. return fmsg, initialmsg
  48.  
  49.  
  50. def errormsg(numberofdevices):
  51. d_broke = []
  52. d_error_message = []
  53. numberofdevices_length = len(numberofdevices)
  54. for i in range(numberofdevices_length):
  55. d_broke.append("0")
  56. d_error_message.append("1")
  57.  
  58. return d_broke, d_error_message
  59.  
  60.  
  61. @client.event
  62. async def on_message(message):
  63. # we do not want the bot to reply to itself
  64. if message.author == client.user:
  65. return
  66.  
  67. if message.content.startswith('!start'):
  68. print(message.author.id)
  69.  
  70. if message.author.id == YourDiscordID:
  71. sock = 1
  72. print("it works!")
  73.  
  74. BOT_MSG, initialmsg = initial_msg(Phone_uuids)
  75.  
  76. fmsg = await client.send_message(message.channel, initialmsg)
  77. d_broke, d_error_message = errormsg(Phone_uuids)
  78. while sock == 1:
  79.  
  80.  
  81. time.sleep(5)
  82. try:
  83.  
  84. cnx = mysql.connector.connect(user=config.user, password=config.password,
  85. host=config.host, port=config.port,
  86. database=config.database)
  87.  
  88. cursor = cnx.cursor()
  89.  
  90. cursor.execute("SELECT uuid, last_seen,instance_name FROM "+config.database+".device")
  91. except:
  92. time.sleep(10)
  93. print("MYSQL CONNECTION ISSUE")
  94. print("MYSQL CONNECTION ISSUE")
  95. print("MYSQL CONNECTION ISSUE")
  96. print("MYSQL CONNECTION ISSUE")
  97. print("MYSQL CONNECTION ISSUE")
  98. cnx = mysql.connector.connect(user=config.user, password=config.password,
  99. host=config.host, port=config.port,
  100. database=config.database)
  101.  
  102. cursor = cnx.cursor()
  103.  
  104. cursor.execute("SELECT uuid, last_seen,instance_name FROM " + config.database + ".device")
  105. print("MYSQL CONNECTION FIXED")
  106. sep = '-----------------------------'
  107.  
  108. # DO NOT TOUCH BELOW
  109. # DO NOT TOUCH BELOW
  110. # DO NOT TOUCH BELOW
  111. # DO NOT TOUCH BELOW
  112. # Literally so delicate you could break everything :(
  113. for (uuid, last_seen, instance_name) in cursor:
  114. editedmsg = ""
  115. print("{}, {} ".format(
  116. uuid, last_seen, instance_name))
  117. times = time.time()
  118. int(times)
  119. print("THE CURRENT TIME IS: " + str(times) + "\n\n\n\n")
  120. int(times)
  121. Phone_uuids_length = len(Phone_uuids)
  122. for i in range(Phone_uuids_length):
  123.  
  124. if uuid == Phone_uuids[i]:
  125. i1[i] = instance_name
  126.  
  127. if last_seen > (times - 12000):
  128. BOT_MSG[i][2] = ': :no_mobile_phones:'
  129. if d_broke[i] == "1" and d_error_message[i] == "0":
  130. await client.send_message(message.author, uuid + " is Having Trouble!!")
  131. d_error_message[i] = "1"
  132. d_broke[i] = "1"
  133.  
  134. if last_seen > (times - 400):
  135. BOT_MSG[i][2] = ": :warning:"
  136. d_broke[i] = "0"
  137.  
  138. if last_seen > (times - 30):
  139. BOT_MSG[i][2] = ": :white_check_mark:"
  140. d_broke[i] = "0"
  141. d_error_message[i] = "0"
  142. print("Device is up")
  143.  
  144. cursor.close()
  145. cnx.close()
  146.  
  147. datetime.datetime.now()
  148.  
  149. datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
  150. for i in range(Phone_uuids_length):
  151. editedmsg += (
  152. Phone_uuids[i] + ": " + BOT_MSG[i][2] + '\n')
  153. try:
  154. await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
  155. datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
  156. except:
  157. time.sleep(5)
  158.  
  159. try:
  160. await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
  161. datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
  162. except:
  163. time.sleep(20)
  164. try:
  165. await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
  166. datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
  167. except:
  168. time.sleep(60)
  169. print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
  170. print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
  171. print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
  172. print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
  173. print("IF YOU SEE THIS THERE IS A CONNECTION ISSUE SOMEWHERE")
  174. await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
  175. datetime.datetime.now()) + "**\n:no_mobile_phones: Means dead")
  176.  
  177.  
  178.  
  179. @client.event
  180. async def on_ready():
  181.  
  182. print('Logged in as')
  183. print(client.user.name)
  184. print(client.user.id)
  185. print('------')
  186.  
  187. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement