Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import logging
- from discord_webhook import DiscordWebhook,DiscordEmbed
- # --------------------------------discord config-----------------------------
- discordUrl = "https://discordapp.com/api/webhooks/731656806014648320/gWQpDcgVgzTwwkRRjfSoiLmk4bmmywN_17grLbqcDXE_9A6VwFTSCk8P9ProoEFceJWg"
- # ---------------------------------Class Declaration-------------------------
- class Player:
- name = None
- hiscore_url = None
- player_url = None
- thumbnail = None
- def __init__(self, name, hiscore_url,player_thumbnail):
- self.name = name
- self.hiscore_url = hiscore_url
- self.thumbnail = player_thumbnail
- # creating 'Skill' objects for 'self' ( which is each object of 'Player' )
- self.Overall = Skill(1098762, "https://i.imgur.com/bX8yAwW.png")
- self.Attack = Skill(7368816, "https://i.imgur.com/ieVoUt8.png")
- self.Defence = Skill(4342338, "https://i.imgur.com/fu7roAC.png")
- self.Strength = Skill(13415993, "https://i.imgur.com/fgWiDC4.png" )
- self.Hitpoints = Skill(12191238, "https://i.imgur.com/tDG1vpS.png")
- self.Ranged = Skill(8170752, "https://i.imgur.com/c5tivGa.png")
- self.Prayer = Skill(16448250, "https://i.imgur.com/b6HHA0U.png")
- self.Magic = Skill(21196, "https://i.imgur.com/9hAooHz.png")
- self.Cooking = Skill(13417984, "https://i.imgur.com/Le5Uh5S.png")
- self.Woodcutting = Skill(761344, "https://i.imgur.com/zx8YTKx.png")
- self.Fletching = Skill(5743441, "https://i.imgur.com/W9bcv5c.png")
- self.Fishing = Skill(4288883, "https://i.imgur.com/t2xHAjp.png")
- self.Firemaking = Skill(15760142, "https://i.imgur.com/dK1SQ7b.png")
- self.Crafting = Skill(6375214, "https://i.imgur.com/HBkf6AA.png")
- self.Smithing = Skill(6052182, "https://i.imgur.com/lSVT1Wj.png")
- self.Mining = Skill(2897541, "https://i.imgur.com/RX24N9A.png")
- self.Herblore = Skill(1534737, "https://i.imgur.com/7m19V7r.png")
- self.Agility = Skill(5388313, "https://i.imgur.com/GSO4w4y.png")
- self.Thieving = Skill(197379, "https://i.imgur.com/qm0oJnd.png")
- self.Slayer = Skill(12762114, "https://i.imgur.com/uDHeiNw.png")
- self.Farming = Skill(697233, "https://i.imgur.com/9yJvyxc.png")
- self.Runecrafting = Skill(7211207, "https://i.imgur.com/aJ9MrnP.png")
- self.Hunter = Skill(6372356, "https://i.imgur.com/gvTsaxl.png")
- self.Construction = Skill(12885512, "https://i.imgur.com/lLrIp2H.png")
- # creating 'Activity' objects for 'self' ( which is each object of 'Player' )
- self.leaguePoints = Activity()
- self.bountyHunter = Activity()
- self.bountyRogue = Activity()
- self.clueAll = Activity()
- self.clueBeginner = Activity()
- self.clueEasy = Activity()
- self.clueMedium = Activity()
- self.clueHard = Activity()
- self.clueElite = Activity()
- self.clueMaster = Activity()
- self.LMS = Activity()
- self.abyssalSire = Activity()
- self.alchemicalHydra = Activity()
- self.barrowsChests = Activity()
- self.bryophyta = Activity()
- self.callisto = Activity()
- self.cerberus = Activity()
- self.chambersOfXeric = Activity()
- self.chambersOfXericChallenge = Activity()
- self.chaosElemental = Activity()
- self.chaosFanatic = Activity()
- self.commanderZilyana = Activity()
- self.corporealBeast = Activity()
- self.crazyArchaeologist = Activity()
- self.dagannothPrime = Activity()
- self.dagganothRex = Activity()
- self.dagganothSupreme = Activity()
- self.derangedArchaeologist = Activity()
- self.generalGraardor = Activity()
- self.giantMole = Activity()
- self.grotesqueGuardians = Activity()
- self.hespori = Activity()
- self.kalphiteQueen = Activity()
- self.kingBlackDragon = Activity()
- self.kraken = Activity()
- self.kreearra = Activity()
- self.kriltsutsaroth = Activity()
- self.mimic = Activity()
- self.nightmare = Activity()
- self.obor = Activity()
- self.sarachnis = Activity()
- self.scorpia = Activity()
- self.skotizo = Activity()
- self.theGauntlet = Activity()
- self.theCorruptedGauntlet = Activity()
- self.theatreOfBlood = Activity()
- self.ThermonuclearSmokeDevil = Activity()
- self.tzKalZuk = Activity()
- self.tzTokJad = Activity()
- self.venenatis = Activity()
- self.vetion = Activity()
- self.vorkath = Activity()
- self.wintertodt = Activity()
- self.zalcano = Activity()
- self.zulrah = Activity()
- class Skill:
- rank = None
- level = None
- xp = None
- last_level = None
- colour = None
- icon_url = None
- def __init__(self, colour, icon_url):
- self.colour = colour
- self.icon_url = icon_url
- class Activity:
- rank = None
- count = None
- last_count = None
- # --------------------------------------Function Declaration & Definition---------------------------
- def statusCheck(status_code, name):
- if status_code != 200:
- print(f"Api Request Failed for {name}")
- else:
- print(f"{name}'s Request Successful")
- return
- def storeData(data_processed, player, first_run):
- line_count = 0
- for line in data_processed:
- if line != '':
- skill_data = line.split(',')
- if line_count < 24:
- player_skill = None
- player_skill = getattr(player, skills[line_count])
- player_skill.rank = skill_data[0]
- player_skill.level = skill_data[1]
- player_skill.xp = skill_data[2]
- line_count = line_count + 1
- if player_skill.last_level != player_skill.level and first_run is not True:
- logging.info(player.name, "Gained A Level in ", skills[line_count])
- pushLevelUp(discordUrl,skills[line_count-1], player, player_skill)
- player_skill.last_level = skill_data[1]
- elif line_count < 79:
- player_activity = getattr(player, activity[line_count - 24])
- player_activity.last_count = player_activity.count
- player_activity.rank = skill_data[0]
- player_activity.count = skill_data[1]
- line_count = line_count + 1
- def pushLevelUp(url, skill, player, player_skill):
- overall = getattr(player, skills[0])
- message = DiscordWebhook(url)
- embed = DiscordEmbed(title=f"Reached {skill} Level : {player_skill.level}!",
- description=f"Total {skill} XP : {int(player_skill.xp):,}", color=player_skill.colour)
- embed.set_author(name=f"{player.name}", icon_url=f"{player.thumbnail}")
- embed.set_image(url=player_skill.icon_url)
- embed.add_embed_field(name="Overall Skill Level", value=f"{int(overall.level):,}")
- embed.add_embed_field(name="Overall Skill XP", value=f"{int(overall.xp):,}")
- message.add_embed(embed)
- post = message.execute()
- time.sleep(1)
- skills = ['Overall', 'Attack', 'Defence', 'Strength', 'Hitpoints', 'Ranged', 'Prayer', 'Magic', 'Cooking',
- 'Woodcutting', 'Fletching', 'Fishing', 'Firemaking', 'Crafting', 'Smithing', 'Mining', 'Herblore',
- 'Agility', 'Thieving', 'Slayer', 'Farming', 'Runecrafting', 'Hunter', 'Construction']
- activity = ['leaguePoints', 'bountyHunter', 'bountyRogue', 'clueAll', 'clueBeginner', 'clueEasy', 'clueMedium',
- 'clueHard', 'clueElite', 'clueMaster', 'LMS', 'abyssalSire', 'alchemicalHydra', 'barrowsChests',
- 'bryophyta', 'callisto', 'cerberus', 'chambersOfXeric', 'chambersOfXericChallenge', 'chaosElemental',
- 'chaosFanatic', 'commanderZilyana', 'corporealBeast', 'crazyArchaeologist', 'dagannothPrime',
- 'dagganothRex', 'dagganothSupreme', 'derangedArchaeologist', 'generalGraardor', 'giantMole',
- 'grotesqueGuardians', 'hespori', 'kalphiteQueen', 'kingBlackDragon', 'kraken', 'kreearra', 'kriltsutsaroth',
- 'mimic', 'nightmare', 'obor', 'sarachnis', 'scorpia', 'skotizo', 'theGauntlet', 'theCorruptedGauntlet',
- 'theatreOfBlood', 'ThermonuclearSmokeDevil', 'tzKalZuk', 'tzTokJad', 'venenatis', 'vetion', 'vorkath',
- 'wintertodt', 'zalcano', 'zulrah']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement