summaryrefslogtreecommitdiff
path: root/check.py
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2015-01-06 23:38:42 +0100
committerjomo <github@jomo.tv>2015-01-06 23:38:42 +0100
commit9a916ed2cd9440d46079f9b7db421a7b9fcbf6ee (patch)
tree3af33b3ddc2fa3159f9243b0ade09b3e3cc96425 /check.py
parent3435e994326b14f700777741a76dd990a2bc703f (diff)
change indentation from 2 spaces to 4, fix #5
Diffstat (limited to 'check.py')
-rw-r--r--check.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/check.py b/check.py
index 575c6ad..701bbdf 100644
--- a/check.py
+++ b/check.py
@@ -6,59 +6,59 @@ from helpers import *
# receive info based on the user's IP. information provided by ipinfo.io
def ip_info(player):
- data = json.load(urllib2.urlopen("http://ipinfo.io%s/json" % str(player.getAddress().getAddress())))
- return data
+ data = json.load(urllib2.urlopen("http://ipinfo.io%s/json" % str(player.getAddress().getAddress())))
+ return data
# receive first join date based on the player data (may not be accurate)
def get_first_join(player):
- first_join = int(player.getFirstPlayed())
- dt = datetime.datetime.fromtimestamp(first_join/1000.0)
- return "%s-%s-%s %s:%s:%s" % (str(dt.year), str(dt.month), str(dt.day), str(dt.hour), str(dt.minute), str(dt.second))
+ first_join = int(player.getFirstPlayed())
+ dt = datetime.datetime.fromtimestamp(first_join/1000.0)
+ return "%s-%s-%s %s:%s:%s" % (str(dt.year), str(dt.month), str(dt.day), str(dt.hour), str(dt.minute), str(dt.second))
# receive country based on the user's IP
def get_country(data):
- return str(data.get("country"))
+ return str(data.get("country"))
def get_all_names(player):
- uuid = str(player.getUniqueId()).replace("-", "")
- names = json.load(urllib2.urlopen("https://api.mojang.com/user/profiles/%s/names" % uuid))
- return ", ".join(names)
+ uuid = str(player.getUniqueId()).replace("-", "")
+ names = json.load(urllib2.urlopen("https://api.mojang.com/user/profiles/%s/names" % uuid))
+ return ", ".join(names)
# combines data
def get_all_data(sender, player):
- data = ip_info(player)
+ data = ip_info(player)
- msg(sender, "")
-
- try:
- msg(sender, "&7 -- Data provided by Redstoner")
- msg(sender, "&6> UUID: &e%s" % str(player.getUniqueId()))
- msg(sender, "&6> First joined: &7(y-m-d h:m:s) &e%s" % get_first_join(player))
msg(sender, "")
- msg(sender, "&7 -- Data provided by ipinfo.io")
- msg(sender, "&6> Country: &e%s" % get_country(data))
- msg(sender, "&7 -- Data provided by Mojang")
- msg(sender, "&6> All ingame names used so far: &e%s" % get_all_names(player))
- except Exception as e:
- # can throw exceptions such as timeouts when Mojang API is down
- warn(e)
+
+ try:
+ msg(sender, "&7 -- Data provided by Redstoner")
+ msg(sender, "&6> UUID: &e%s" % str(player.getUniqueId()))
+ msg(sender, "&6> First joined: &7(y-m-d h:m:s) &e%s" % get_first_join(player))
+ msg(sender, "")
+ msg(sender, "&7 -- Data provided by ipinfo.io")
+ msg(sender, "&6> Country: &e%s" % get_country(data))
+ msg(sender, "&7 -- Data provided by Mojang")
+ msg(sender, "&6> All ingame names used so far: &e%s" % get_all_names(player))
+ except Exception as e:
+ # can throw exceptions such as timeouts when Mojang API is down
+ warn(e)
@hook.command("check", description="Displays useful stuff about a user", usage="/check <player>")
def on_hook_command(sender, args):
- if sender.hasPermission("utils.check"):
- plugin_header(sender, "Check")
- msg(sender, "&7Please notice that the data may not be fully accurate!")
+ if sender.hasPermission("utils.check"):
+ plugin_header(sender, "Check")
+ msg(sender, "&7Please notice that the data may not be fully accurate!")
- player = server.getPlayer(args[0]) if len(args) > 0 else None
- if player is not None and is_player(player):
- get_all_data(sender, player)
+ player = server.getPlayer(args[0]) if len(args) > 0 else None
+ if player is not None and is_player(player):
+ get_all_data(sender, player)
+ else:
+ msg(sender, "&cLooks like this player is not online.")
else:
- msg(sender, "&cLooks like this player is not online.")
- else:
- msg(sender, "&4You don't have the required permissions to execute this command!")
- return True \ No newline at end of file
+ msg(sender, "&4You don't have the required permissions to execute this command!")
+ return True \ No newline at end of file