Fixed formatting and removed unused imports.

This commit is contained in:
Fletcher Boyd 2013-09-04 18:32:17 +08:00
parent fb62640ccc
commit fa97d4659c
6 changed files with 31 additions and 33 deletions

View file

@ -1,17 +1,21 @@
from util import hook, http
from util import hook
import socket
import struct
try:
import DNS
import DNS
# Please remember to install the dependancy 'pydns'
pydns_installed = True
except ImportError:
pydns_installed = False
def format_motd(motd):
empty = ""
colors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74", u"\x0306,\xa75", u"\x0307,\xa76", u"\x0308,\xa7e", u"\x0309,\xa7a", u"\x0310,\xa73", u"\x0311,\xa7b", u"\x0312,\xa71", u"\x0313,\xa7d", u"\x0314,\xa78", u"\x0315,\xa77", u"\x02,\xa7l", u"\x0310,\xa79", u"\x09,\xa7o", u"\x13,\xa7m", u"\x0f,\xa7r", u"\x15,\xa7n"];
colors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74",
u"\x0306,\xa75", u"\x0307,\xa76", u"\x0308,\xa7e", u"\x0309,\xa7a", u"\x0310,\xa73", u"\x0311,\xa7b",
u"\x0312,\xa71", u"\x0313,\xa7d", u"\x0314,\xa78", u"\x0315,\xa77", u"\x02,\xa7l", u"\x0310,\xa79",
u"\x09,\xa7o", u"\x13,\xa7m", u"\x0f,\xa7r", u"\x15,\xa7n"];
for s in colors:
lcol = s.split(",")
motd = motd.replace(lcol[1], lcol[0])
@ -46,8 +50,8 @@ def mcping_connect(host, port):
return message
except:
return "Error pinging " + host + ":" + str(port) +\
", is it up? Double-check your address!"
return "Error pinging " + host + ":" + str(port) + \
", is it up? Double-check your address!"
def srvData(domain):
@ -57,13 +61,13 @@ def srvData(domain):
for getsrv in srv_result.answers:
if getsrv['typename'] == 'SRV':
data = [getsrv['data'][2],getsrv['data'][3]]
data = [getsrv['data'][2], getsrv['data'][3]]
return data
@hook.command
def mcping(inp):
"mcping <server>[:port] - Ping a Minecraft server to check status."
"""mcping <server>[:port] - Ping a Minecraft server to check status."""
inp = inp.strip().split(" ")[0]
if ":" in inp:
@ -86,7 +90,7 @@ def mcping(inp):
host = str(getdata[1])
port = int(getdata[0])
return format_motd(mcping_connect(host, port))
except:
except:
return "Error pinging %s, is it up? Double-check your address!" % inp
else:
return "Error pinging %s, is it up? Double-check your address!" % inp