From 2a33c97f4d12e684379fbdf280d2a1bd61c1f63e Mon Sep 17 00:00:00 2001 From: "Robert \"Red\" English" Date: Fri, 12 Apr 2013 22:45:20 -0300 Subject: [PATCH 1/4] Updated mctools.py to read SRV Records Updated MC Tools to read SRV Records that were implemented in Minecraft 1.3.1 Requires module 'pydns' so please run 'sudo pip install pydns' --- plugins/mctools.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/mctools.py b/plugins/mctools.py index d866988..228512f 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -2,6 +2,7 @@ from util import hook, http import socket import json import struct +import DNS ## Please remember to install the dependancy 'pydns' def mccolorconvert(motd): empty = "" @@ -42,6 +43,15 @@ def mcping_connect(host, port): return "Error pinging " + host + ":" + str(port) +\ ", is it up? Double-check your address!" +def srvData(domain): + DNS.ParseResolvConf() + srv_req = DNS.Request(qtype = 'srv') + srv_result = srv_req.req('_minecraft._tcp.%s' % domain) + + for getsrv in srv_result.answers: + if getsrv['typename'] == 'SRV': + data = [getsrv['data'][2],getsrv['data'][3]] + return data @hook.command(autohelp=False) def mclogin(inp, bot=None): @@ -106,6 +116,7 @@ def mcping(inp): "mcping [:port] - Ping a Minecraft server to check status." inp = inp.strip().split(" ")[0] + if ":" in inp: host, port = inp.split(":", 1) try: @@ -113,7 +124,12 @@ def mcping(inp): except: return "error: invalid port!" else: - host = inp - port = 25565 + try: + getdata = srvData(inp) + host = inp + port = getdata[0] + except: + host = inp + port = 25565 return mccolorconvert(mcping_connect(host, port)) From 6bc35605e5e206f14a0fcd3832841a401b0501ac Mon Sep 17 00:00:00 2001 From: "Robert \"Red\" English" Date: Fri, 12 Apr 2013 23:16:49 -0300 Subject: [PATCH 2/4] Fixed Host Error in mctools.py --- plugins/mctools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mctools.py b/plugins/mctools.py index 228512f..c47d11c 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -126,8 +126,8 @@ def mcping(inp): else: try: getdata = srvData(inp) - host = inp - port = getdata[0] + host = str(getdata[1]) + port = int(getdata[0]) except: host = inp port = 25565 From 57dc9bbaf6e4da776c5ecba84f838fa6bdb6e41b Mon Sep 17 00:00:00 2001 From: "Robert \"Red\" English" Date: Mon, 15 Apr 2013 13:40:27 -0300 Subject: [PATCH 3/4] Updated README.md to have a reference to 'pydns' --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 512ab57..e3bc97c 100755 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Linux packages needed for install: python, python-dev, libenchant-dev, libenchan CloudBot runs on **Python** *2.7.x*. It is developed on **Ubuntu** *12.04* with **Python** *2.7.3*. It **requires the Python module** `lXML`, and `Enchant` is needed for the spellcheck plugin. +It also **requires** `pydns` and is needed for SRV record lookup for the mctools plugin. The programs `daemon` or `screen` are recomended for the launcher to run optimaly. From 29ec9047775164b182232eb4a82ad6edceb51f2b Mon Sep 17 00:00:00 2001 From: "Robert \"Red\" English" Date: Mon, 15 Apr 2013 13:41:41 -0300 Subject: [PATCH 4/4] Updated requirements.txt to contain 'pydns' --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 91c1f29..0759413 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ BeautifulSoup==3.2.1 lxml==3.1beta1 pyenchant==1.6.5 +pydns>=2.3.6