Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. import time
  2. import mysql.connector
  3. import datetime
  4.  
  5.  
  6. # Work with Python 3.6
  7. import discord
  8.  
  9. # Welcome to Ataku's Device Checker Bot for RDM. Follow the instructions in README to setup completely.
  10. # Welcome to Ataku's Device Checker Bot for RDM. Follow the instructions in README to setup completely.
  11. # Welcome to Ataku's Device Checker Bot for RDM. Follow the instructions in README to setup completely.
  12. # Welcome to Ataku's Device Checker Bot for RDM. Follow the instructions in README to setup completely.
  13. # Welcome to Ataku's Device Checker Bot for RDM. Follow the instructions in README to setup completely.
  14.  
  15.  
  16. TOKEN = 'NTAwNDkwNDc3ODU5MTEwOTE4.Du99Cg.5hT7y0VQ4PXZARs9-W8h0o39qvU' # Token for the Bot
  17.  
  18. YourDiscordID = '2136307xxxx428480' # The ID of YOUR Discord Account (Allows only you to start the bot)
  19.  
  20.  
  21.  
  22.  
  23. Phone_uuids = ["0c4acee9f496aeaca5dde1b2151fbc2170593439", "ea7f2aeb91cefe1131a0d70a03d433562fd7b8aa"]
  24. # Add phone uuids like: ["phoneuuid1", "phoneuuid2"] etc etc
  25.  
  26. editedmsg = "" # IGNORE THIS DO NOT CHANGE IT
  27. devicecount = 0 # IGNORE THIS DO NOT CHANGE IT
  28. for i in Phone_uuids:
  29. devicecount = devicecount + 1
  30.  
  31. # Add as many phone ids as you want :) - Ataku
  32.  
  33. client = discord.Client()
  34.  
  35.  
  36. def initial_msg(deviceids):
  37. initialmsg = ""
  38. fmsg = []
  39. deviceids_length = len(deviceids)
  40. for i in range(deviceids_length):
  41. fmsg.append(["\nDevice ", i, " About to check device..."])
  42. initialmsg += (fmsg[i][0] + str(fmsg[i][1] + 1) + fmsg[i][2])
  43.  
  44. return fmsg, initialmsg
  45.  
  46.  
  47. def errormsg(numberofdevices):
  48. d_broke = []
  49. d_error_message = []
  50. numberofdevices_length = len(numberofdevices)
  51. for i in range(numberofdevices_length):
  52. d_broke.append(False)
  53. d_error_message.append(True)
  54.  
  55. return d_broke, d_error_message
  56.  
  57.  
  58. @client.event
  59. async def on_message(message):
  60. # we do not want the bot to reply to itself
  61. if message.author == client.user:
  62. return
  63.  
  64. if message.content.startswith('!start'):
  65. print(message.author.id)
  66.  
  67. if message.author.id == YourDiscordID:
  68. sock = 1
  69. print("it works!")
  70.  
  71. BOT_MSG, initialmsg = initial_msg(Phone_uuids)
  72.  
  73. fmsg = await client.send_message(message.channel, initialmsg)
  74. while sock == 1:
  75. # PART 2 HERE
  76. # PART 2 HERE
  77. # PART 2 HERE
  78. # PART 2 HERE
  79. # PART 2 HERE
  80.  
  81. d_broke, d_error_message = errormsg(Phone_uuids)
  82.  
  83. time.sleep(5)
  84.  
  85. cnx = mysql.connector.connect(user='rdmuser', password='xxxxxx',
  86. host='xxxxxx', port="3306",
  87. database='rdmdb')
  88.  
  89. cursor = cnx.cursor()
  90.  
  91. query = "SELECT uuid, last_seen, instance_name FROM rdmdb.device"
  92.  
  93. cursor.execute(query)
  94.  
  95. sep = '-----------------------------'
  96.  
  97. # DO NOT TOUCH BELOW
  98. # DO NOT TOUCH BELOW
  99. # DO NOT TOUCH BELOW
  100. # DO NOT TOUCH BELOW
  101. # Literally so delicate you could break everything :(
  102. for (uuid, last_seen, instance_name) in cursor:
  103. editedmsg = ""
  104. print("{}, {} ".format(
  105. uuid, last_seen, instance_name))
  106. times = time.time()
  107. int(times)
  108. print("THE CURRENT TIME IS: " + str(times) + "\n\n\n\n")
  109. int(times)
  110. Phone_uuids_length = len(Phone_uuids)
  111. for i in range(Phone_uuids_length):
  112.  
  113. if uuid == Phone_uuids[i]:
  114. i1 = instance_name
  115.  
  116. if last_seen > (times - 2000):
  117. BOT_MSG[i][2] = ': Device is broken FIX'
  118. if d_broke[i] is True and d_error_message[i] is False:
  119. await client.send_message(message.author, ("Device ", BOT_MSG[i][1], "is Broken!"))
  120. d_error_message[i] = True
  121. d_broke[i] = True
  122.  
  123. if last_seen > (times - 100):
  124. BOT_MSG[i][2] = ": Device is currently experiencing a error"
  125. d_broke[i] = False
  126.  
  127. if last_seen >= (times - 50):
  128. BOT_MSG[i][2] = ": Device is currently experiencing a delay"
  129. d_broke[i] = False
  130.  
  131. if last_seen > (times - 30):
  132. BOT_MSG[i][2] = ": Device is Online"
  133. d_broke[i] = False
  134. d_error_message[i] = False
  135. print("Device is up")
  136.  
  137. cursor.close()
  138. cnx.close()
  139.  
  140. datetime.datetime.now()
  141.  
  142. datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
  143. for i in range(Phone_uuids_length):
  144. editedmsg += (BOT_MSG[i][0] + str(BOT_MSG[i][1] + 1) + BOT_MSG[i][
  145. 2] + '\n\n' + 'Current Work: ' + i1 + '\n' + sep + '\n\n')
  146.  
  147. await client.edit_message(fmsg, new_content=editedmsg + '\n\n**Last Update: ' + str(
  148. datetime.datetime.now()) + "**")
  149. print("was the messaged edited?")
  150.  
  151.  
  152. @client.event
  153. async def on_ready():
  154. print('Logged in as')
  155. print(client.user.name)
  156. print(client.user.id)
  157. print('------')
  158.  
  159.  
  160. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement