diff options
author | jomo <github@jomo.tv> | 2014-08-10 05:18:06 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-08-10 05:18:06 +0200 |
commit | 6f16ed15ea16fdf82276beed3e3686b9e5d262f0 (patch) | |
tree | ad45afecf421ad3b44780cd04b9e07d2ef1d0742 /check.py | |
parent | ad4fb7a7008583c4d58b8f029d72333cc17d0903 (diff) |
small cleanup
Diffstat (limited to 'check.py')
-rw-r--r-- | check.py | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,29 +1,33 @@ import json import urllib2 import datetime - 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 + # 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)) + # receive country based on the user's IP def get_country(data): 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) + # combines data def get_all_data(sender, player): data = ip_info(player) @@ -32,19 +36,18 @@ def get_all_data(sender, player): try: msg(sender, "&7 -- Data provided by Redstoner") - msg(sender, "&6> Unique User ID: &e%s" % str(player.getUniqueId())) + 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 Mojang") msg(sender, "&6> Country: &e%s" % get_country(data)) 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 sometimes + # can throw exceptions such as timeouts when Mojang API is down warn(e) - -@hook.command("check", description="Displays useful stuff about a user", aliases="ck", usage="/check <player>") +@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") |