Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import hypixel
from time import time
from random import shuffle
print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))
API_KEY = os.environ['apikey']
hypixel.setKeys([API_KEY])
start = time() # Start timer.
for i in range(0, Repeats-1):
shuffle(ActualData) # Randomize the order of the data
for InputUUID in ActualData:
Player = hypixel.Player(InputUUID)
print(Player.getPlayerInfo())
end = time()
totalTime = start-end
print("\nDone! Speed test finished. Time taken: {}".format(end-start))
""" Travis Ci Tests """
import os
import hypixel
import time
API_KEY = os.environ['apikey']
start = time.time()
hypixel.setKeys([API_KEY])
Snuggle = hypixel.Player('8998bcff9765438bb6089ab93bfad4d3')
SnuggleLevel = Snuggle.getLevel()
if SnuggleLevel > 0:
print("Snuggle's is level {}.".format(SnuggleLevel))
else:
raise ValueError(SnuggleLevel)
SnuggleRank = Snuggle.getRank()
if SnuggleRank['rank'] == "Moderator":
print("Snuggle's is a {}.".format(SnuggleRank))
else:
raise ValueError(SnuggleRank)
SnuggleKarma = Snuggle.JSON['karma']
if SnuggleKarma > 0:
print("Snuggle has {} karma.".format(SnuggleKarma))
import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import hypixel
import time
print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))
API_KEY = os.environ['apikey']
hypixel.setKeys([API_KEY])
TestFailed = False
for player in ActualData:
TestPlayer = hypixel.Player(player['Name'])
for test in player:
method_to_call = getattr(TestPlayer, 'get' + test)
testdata = method_to_call()
if testdata == player[test]:
print("\U00002714 {}".format(testdata))
else:
print("\U0000274C {}, Expected: {} [FAILED]".format(testdata, player[test]))
TestFailed = True
print("UUID: {}\n".format(TestPlayer.UUID))
if TestFailed is True:
raise ValueError
print("\nDone! All tests finished.")
""" This is an example of how you can use this API to create cool things.
Just run this and you should see cool stuff. c:"""
import hypixel
API_KEYS = ['API_KEY_HERE_PLS']
hypixel.setKeys(API_KEYS) # This sets the API keys that are going to be used.
Player = hypixel.Player('Snuggle') # This creates a Player-object and puts it to a variable called "Player".
PlayerName = Player.getName() # This gets the player's name and puts it in a variable called "PlayerName". :3
print("Player is called ", end='')
print(PlayerName)
PlayerLevel = Player.getLevel()
print(PlayerName + " is level: ", end='')
print(PlayerLevel) # This prints the level that we got, two lines up!
PlayerRank = Player.getRank()
print(PlayerName + " is rank: ", end='')
print(PlayerRank['rank'])
""" This is an example of how you can use this API to create cool things.
Just run this and you should see cool stuff. c:"""
import hypixel
API_KEYS = ['API_KEY_HERE_PLS', 'ANOTHER_API_KEY?', 'Etc.']
hypixel.setKeys(API_KEYS) # This sets the API keys that are going to be used.
options = ['rank', 'level', 'karma', 'twitter']
while True:
mahInput = input("\nPlease give me a Minecraft username/UUID: ")
optionInput = input("Please select from list: {}\n> ".format(options))
player = hypixel.Player(mahInput) # Creates a hypixel.Player object using the input.
try:
if optionInput.lower() == "rank": # If user selects rank,
print("The player is rank: " + player.getRank()['rank']) # Get the rank and print it.
print("Were they previously a staff member? {}".format(player.getRank()['wasStaff']))
elif optionInput.lower() == "level":
print("The player is level: " + str(player.getLevel())) # Print the player's low level!
elif optionInput.lower() == "karma":
print("The player has {} karma.".format(player.JSON['karma'])) # +25 karma ;)
elif optionInput.lower() == "twitter": # Okay this is a little more complicated
try:
socialMedias = player.JSON['socialMedia']['links'] # Check their social media
print(socialMedias['TWITTER']) # And if they have a Twitter account, print it.
except KeyError: # If an error comes up, saying they don't have a twitter account...