Advertisement
Guest User

Untitled

a guest
Jul 12th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.36 KB | None | 0 0
  1. import time
  2. import logging
  3. from discord_webhook import DiscordWebhook,DiscordEmbed
  4.  
  5.  
  6. # --------------------------------discord config-----------------------------
  7.  
  8. discordUrl = "https://discordapp.com/api/webhooks/731656806014648320/gWQpDcgVgzTwwkRRjfSoiLmk4bmmywN_17grLbqcDXE_9A6VwFTSCk8P9ProoEFceJWg"
  9.  
  10. # ---------------------------------Class Declaration-------------------------
  11.  
  12.  
  13. class Player:
  14.  
  15. name = None
  16. hiscore_url = None
  17. player_url = None
  18. thumbnail = None
  19.  
  20. def __init__(self, name, hiscore_url,player_thumbnail):
  21. self.name = name
  22. self.hiscore_url = hiscore_url
  23. self.thumbnail = player_thumbnail
  24. # creating 'Skill' objects for 'self' ( which is each object of 'Player' )
  25. self.Overall = Skill(1098762, "https://i.imgur.com/bX8yAwW.png")
  26. self.Attack = Skill(7368816, "https://i.imgur.com/ieVoUt8.png")
  27. self.Defence = Skill(4342338, "https://i.imgur.com/fu7roAC.png")
  28. self.Strength = Skill(13415993, "https://i.imgur.com/fgWiDC4.png" )
  29. self.Hitpoints = Skill(12191238, "https://i.imgur.com/tDG1vpS.png")
  30. self.Ranged = Skill(8170752, "https://i.imgur.com/c5tivGa.png")
  31. self.Prayer = Skill(16448250, "https://i.imgur.com/b6HHA0U.png")
  32. self.Magic = Skill(21196, "https://i.imgur.com/9hAooHz.png")
  33. self.Cooking = Skill(13417984, "https://i.imgur.com/Le5Uh5S.png")
  34. self.Woodcutting = Skill(761344, "https://i.imgur.com/zx8YTKx.png")
  35. self.Fletching = Skill(5743441, "https://i.imgur.com/W9bcv5c.png")
  36. self.Fishing = Skill(4288883, "https://i.imgur.com/t2xHAjp.png")
  37. self.Firemaking = Skill(15760142, "https://i.imgur.com/dK1SQ7b.png")
  38. self.Crafting = Skill(6375214, "https://i.imgur.com/HBkf6AA.png")
  39. self.Smithing = Skill(6052182, "https://i.imgur.com/lSVT1Wj.png")
  40. self.Mining = Skill(2897541, "https://i.imgur.com/RX24N9A.png")
  41. self.Herblore = Skill(1534737, "https://i.imgur.com/7m19V7r.png")
  42. self.Agility = Skill(5388313, "https://i.imgur.com/GSO4w4y.png")
  43. self.Thieving = Skill(197379, "https://i.imgur.com/qm0oJnd.png")
  44. self.Slayer = Skill(12762114, "https://i.imgur.com/uDHeiNw.png")
  45. self.Farming = Skill(697233, "https://i.imgur.com/9yJvyxc.png")
  46. self.Runecrafting = Skill(7211207, "https://i.imgur.com/aJ9MrnP.png")
  47. self.Hunter = Skill(6372356, "https://i.imgur.com/gvTsaxl.png")
  48. self.Construction = Skill(12885512, "https://i.imgur.com/lLrIp2H.png")
  49. # creating 'Activity' objects for 'self' ( which is each object of 'Player' )
  50. self.leaguePoints = Activity()
  51. self.bountyHunter = Activity()
  52. self.bountyRogue = Activity()
  53. self.clueAll = Activity()
  54. self.clueBeginner = Activity()
  55. self.clueEasy = Activity()
  56. self.clueMedium = Activity()
  57. self.clueHard = Activity()
  58. self.clueElite = Activity()
  59. self.clueMaster = Activity()
  60. self.LMS = Activity()
  61. self.abyssalSire = Activity()
  62. self.alchemicalHydra = Activity()
  63. self.barrowsChests = Activity()
  64. self.bryophyta = Activity()
  65. self.callisto = Activity()
  66. self.cerberus = Activity()
  67. self.chambersOfXeric = Activity()
  68. self.chambersOfXericChallenge = Activity()
  69. self.chaosElemental = Activity()
  70. self.chaosFanatic = Activity()
  71. self.commanderZilyana = Activity()
  72. self.corporealBeast = Activity()
  73. self.crazyArchaeologist = Activity()
  74. self.dagannothPrime = Activity()
  75. self.dagganothRex = Activity()
  76. self.dagganothSupreme = Activity()
  77. self.derangedArchaeologist = Activity()
  78. self.generalGraardor = Activity()
  79. self.giantMole = Activity()
  80. self.grotesqueGuardians = Activity()
  81. self.hespori = Activity()
  82. self.kalphiteQueen = Activity()
  83. self.kingBlackDragon = Activity()
  84. self.kraken = Activity()
  85. self.kreearra = Activity()
  86. self.kriltsutsaroth = Activity()
  87. self.mimic = Activity()
  88. self.nightmare = Activity()
  89. self.obor = Activity()
  90. self.sarachnis = Activity()
  91. self.scorpia = Activity()
  92. self.skotizo = Activity()
  93. self.theGauntlet = Activity()
  94. self.theCorruptedGauntlet = Activity()
  95. self.theatreOfBlood = Activity()
  96. self.ThermonuclearSmokeDevil = Activity()
  97. self.tzKalZuk = Activity()
  98. self.tzTokJad = Activity()
  99. self.venenatis = Activity()
  100. self.vetion = Activity()
  101. self.vorkath = Activity()
  102. self.wintertodt = Activity()
  103. self.zalcano = Activity()
  104. self.zulrah = Activity()
  105.  
  106.  
  107. class Skill:
  108. rank = None
  109. level = None
  110. xp = None
  111. last_level = None
  112. colour = None
  113. icon_url = None
  114.  
  115. def __init__(self, colour, icon_url):
  116. self.colour = colour
  117. self.icon_url = icon_url
  118.  
  119. class Activity:
  120. rank = None
  121. count = None
  122. last_count = None
  123.  
  124. # --------------------------------------Function Declaration & Definition---------------------------
  125.  
  126.  
  127. def statusCheck(status_code, name):
  128. if status_code != 200:
  129. print(f"Api Request Failed for {name}")
  130. else:
  131. print(f"{name}'s Request Successful")
  132. return
  133.  
  134.  
  135. def storeData(data_processed, player, first_run):
  136. line_count = 0
  137. for line in data_processed:
  138. if line != '':
  139. skill_data = line.split(',')
  140. if line_count < 24:
  141. player_skill = None
  142. player_skill = getattr(player, skills[line_count])
  143. player_skill.rank = skill_data[0]
  144. player_skill.level = skill_data[1]
  145. player_skill.xp = skill_data[2]
  146. line_count = line_count + 1
  147. if player_skill.last_level != player_skill.level and first_run is not True:
  148. logging.info(player.name, "Gained A Level in ", skills[line_count])
  149. pushLevelUp(discordUrl,skills[line_count-1], player, player_skill)
  150. player_skill.last_level = skill_data[1]
  151.  
  152. elif line_count < 79:
  153. player_activity = getattr(player, activity[line_count - 24])
  154. player_activity.last_count = player_activity.count
  155. player_activity.rank = skill_data[0]
  156. player_activity.count = skill_data[1]
  157. line_count = line_count + 1
  158.  
  159.  
  160. def pushLevelUp(url, skill, player, player_skill):
  161. overall = getattr(player, skills[0])
  162. message = DiscordWebhook(url)
  163. embed = DiscordEmbed(title=f"Reached {skill} Level : {player_skill.level}!",
  164. description=f"Total {skill} XP : {int(player_skill.xp):,}", color=player_skill.colour)
  165. embed.set_author(name=f"{player.name}", icon_url=f"{player.thumbnail}")
  166. embed.set_image(url=player_skill.icon_url)
  167. embed.add_embed_field(name="Overall Skill Level", value=f"{int(overall.level):,}")
  168. embed.add_embed_field(name="Overall Skill XP", value=f"{int(overall.xp):,}")
  169. message.add_embed(embed)
  170. post = message.execute()
  171. time.sleep(1)
  172.  
  173.  
  174. skills = ['Overall', 'Attack', 'Defence', 'Strength', 'Hitpoints', 'Ranged', 'Prayer', 'Magic', 'Cooking',
  175. 'Woodcutting', 'Fletching', 'Fishing', 'Firemaking', 'Crafting', 'Smithing', 'Mining', 'Herblore',
  176. 'Agility', 'Thieving', 'Slayer', 'Farming', 'Runecrafting', 'Hunter', 'Construction']
  177.  
  178.  
  179. activity = ['leaguePoints', 'bountyHunter', 'bountyRogue', 'clueAll', 'clueBeginner', 'clueEasy', 'clueMedium',
  180. 'clueHard', 'clueElite', 'clueMaster', 'LMS', 'abyssalSire', 'alchemicalHydra', 'barrowsChests',
  181. 'bryophyta', 'callisto', 'cerberus', 'chambersOfXeric', 'chambersOfXericChallenge', 'chaosElemental',
  182. 'chaosFanatic', 'commanderZilyana', 'corporealBeast', 'crazyArchaeologist', 'dagannothPrime',
  183. 'dagganothRex', 'dagganothSupreme', 'derangedArchaeologist', 'generalGraardor', 'giantMole',
  184. 'grotesqueGuardians', 'hespori', 'kalphiteQueen', 'kingBlackDragon', 'kraken', 'kreearra', 'kriltsutsaroth',
  185. 'mimic', 'nightmare', 'obor', 'sarachnis', 'scorpia', 'skotizo', 'theGauntlet', 'theCorruptedGauntlet',
  186. 'theatreOfBlood', 'ThermonuclearSmokeDevil', 'tzKalZuk', 'tzTokJad', 'venenatis', 'vetion', 'vorkath',
  187. 'wintertodt', 'zalcano', 'zulrah']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement