Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daboross/7713891 to your computer and use it in GitHub Desktop.
Save daboross/7713891 to your computer and use it in GitHub Desktop.
Cloudbot status patch
From ea8561655227b9513d2aa4cb058465d5aef961ce Mon Sep 17 00:00:00 2001
From: Dabo Ross <daboross@daboross.net>
Date: Wed, 27 Nov 2013 03:25:00 -0800
Subject: [PATCH] Somewhat nicer minecraft status message
---
plugins/minecraft_status.py | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/plugins/minecraft_status.py b/plugins/minecraft_status.py
index 98fce4a..6d1ab3a 100755
--- a/plugins/minecraft_status.py
+++ b/plugins/minecraft_status.py
@@ -1,8 +1,14 @@
from util import hook, http
import json
+yes_prefix = u"\x02\x0f"
+yes_suffix = u": \x033\x02\u2714"
+no_prefix = u"\x02\x0f"
+no_suffix = u": \x034\x02\u2716"
+
@hook.command(autohelp=False)
+@hook.command("mcs", autohelp=False)
def mcstatus(inp):
"""mcstatus -- Checks the status of various Mojang (the creators of Minecraft) servers."""
@@ -14,25 +20,29 @@ def mcstatus(inp):
# lets just reformat this data to get in a nice format
data = json.loads(request.replace("}", "").replace("{", "").replace("]", "}").replace("[", "{"))
- out = []
-
# use a loop so we don't have to update it if they add more servers
- yes = []
- no = []
+ servers = []
for server, status in data.items():
+ if server == "account.mojang.com":
+ server = "MJ|Account"
+ elif server == "skins.minecraft.net":
+ server = "MC|Skins"
+ elif server == "auth.mojang.com":
+ server = "MJ|Auth"
+ elif server == "authserver.mojang.com":
+ server = "MJ|AuthServer"
+ elif server == "login.minecraft.net":
+ server = "MC|Login"
+ elif server == "session.minecraft.net":
+ server = "MC|Session"
+ elif server == "minecraft.net":
+ server = "MC|Website"
+
if status == "green":
- yes.append(server)
+ servers.append(u"{}{}{}".format(yes_prefix, server, yes_suffix))
else:
- no.append(server)
- if yes:
- out = "\x033\x02Online\x02\x0f: " + ", ".join(yes)
- if no:
- out += " "
- if no:
- out += "\x034\x02Offline\x02\x0f: " + ", ".join(no)
-
- return "\x0f" + out.replace(".mojang.com", ".mj") \
- .replace(".minecraft.net", ".mc")
+ servers.append(u"{}{}{}".format(no_prefix, server, no_suffix))
+ return " ".join(servers)
@hook.command("haspaid")
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment