mcuuid/test.py

44 lines
1.2 KiB
Python
Raw Normal View History

### Import our module
from mcuuid.api import GetPlayerData
from mcuuid.tools import is_valid_minecraft_username
from mcuuid.tools import is_valid_mojang_uuid
2015-03-11 20:16:17 +01:00
### Import some other necessary modules
import sys
2015-03-11 20:16:17 +01:00
### Which username should we use?
# Are there some arguments brought by the console use the first after the filename as username
if len(sys.argv) > 1:
identifier = sys.argv[1]
# Else, ask for a username by userinput
else:
print("Please enter a username or UUID: ")
identifier = raw_input()
if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(identifier):
if is_valid_minecraft_username(identifier):
print('Valid username')
if is_valid_mojang_uuid(identifier):
print('Valid UUID')
### Obtaining the playerinformation using our module
player = GetPlayerData(identifier)
# Check if the request was valid and the user exists
if player.valid is True:
# Getting UUID
uuid = player.uuid
# Getting real Username
name = player.username
# Print everything
print('UUID: ' + uuid)
print('correct name: ' + name)
# Error message
else:
print("That player was not found.")
2015-03-11 20:16:17 +01:00
else:
print('identifier is not valid')