From 2a9aa2419d7a1336bd27332c775cf3755ed81775 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 24 Feb 2012 16:17:59 +1300 Subject: [PATCH] test sync --- plugins/dictionary.py | 4 ++-- plugins/fortune.py | 1 - plugins/mctools.py | 7 +++++-- plugins/util/pywhois/parser.py | 2 +- plugins/whois.py | 30 +++++++++++++++++++++++++----- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/plugins/dictionary.py b/plugins/dictionary.py index e50dcf4..0d54592 100644 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -13,7 +13,7 @@ def urban(inp): defs = page['list'] if page['result_type'] == 'no_results': - return 'not found.' + return 'Not found.' out = defs[0]['word'] + ': ' + defs[0]['definition'] @@ -44,7 +44,7 @@ def define(inp): correction = h.xpath('//span[@class="correct-word"]/text()') if correction: - result = 'definition for "%s": ' % correction[0] + result = 'Definition for "%s": ' % correction[0] sections = [] for section in definition: diff --git a/plugins/fortune.py b/plugins/fortune.py index dc76c86..6dcf19e 100644 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -6,7 +6,6 @@ fortunes = ["Help! I'm stuck in the fortune cookie factory!", "He who laughs at himself never runs out of things to laugh at.", "The world is your oyster.", "Today will be a good day.", - "Only listen to the Hoss Fortune Cookies. Disregard all other fortune telling units.", "Life's short, party naked.", "Haters gonna hate.", "You are amazing and let no one tell you otherwise.", diff --git a/plugins/mctools.py b/plugins/mctools.py index c3dd9d5..9a4b525 100644 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -4,8 +4,11 @@ import string @hook.command(autohelp=False) def mcstatus(inp, bot=None): ".mcstatus - Attempts to log in to minecraft" - username = bot.config["api_keys"]["mc_user"] - password = bot.config["api_keys"]["mc_pass"] + username = bot.config.get("api_keys", {}).get("mc_user", None) + password = bot.config.get("api_keys", {}).get("mc_pass", None) + if api_key is None: + return "error: no api key set" + login = http.get("https://login.minecraft.net/?user="+username+"&password="+password+"&version=13") if username.lower() in login.lower(): return "Minecraft login servers appear to be online!" diff --git a/plugins/util/pywhois/parser.py b/plugins/util/pywhois/parser.py index a89f866..72b5215 100644 --- a/plugins/util/pywhois/parser.py +++ b/plugins/util/pywhois/parser.py @@ -133,7 +133,7 @@ class WhoisOrg(WhoisEntry): 'registrar': 'Registrar:\s?(.+)', 'whois_server': 'Whois Server:\s?(.+)', 'referral_url': 'Referral URL:\s?(.+)', # http url of whois_server - 'updated_date': 'Updated Date:\s?(.+)', + 'updated_date': 'Last Updated On:\s?(.+)', 'creation_date': 'Created On:\s?(.+)', 'expiration_date': 'Expiration Date:\s?(.+)', 'name_servers': 'Name Server:\s?(.+)', # list of name servers diff --git a/plugins/whois.py b/plugins/whois.py index 35eed11..682a984 100644 --- a/plugins/whois.py +++ b/plugins/whois.py @@ -9,11 +9,31 @@ def whois(inp, say=None): print w - domain_name = w.domain_name[0] - expiration_date = w.expiration_date[0] - creation_date = w.creation_date[0] - registrant_email = w.emails[0] - administrative_email = w.emails[1] + try: + domain_name = w.domain_name[0] + except IndexError, e: + domain_name: "none." + + try: + expiration_date = w.expiration_date[0] + except IndexError, e: + expiration_date: "none." + + try: + creation_date = w.creation_date[0] + except IndexError, e: + creation_date: "none." + + try: + registrant_email = w.emails[0] + except: + registrant_email: "none." + + try: + administrative_email = w.emails[1] + except: + administrative_email: "none." + say('Domain recognised! %s was registered on \x02%s\x02 and will expire on \x02%s\x02' % (domain_name, creation_date, expiration_date)) say('Registrant email: %s Administrative email: %s' % (registrant_email, administrative_email))