From 13d284a86183cf8e56bd1d6636103f3d69b6b30d Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 4 Sep 2013 20:27:46 +1200 Subject: [PATCH 1/5] standarised format of drama.py to match other plugins --- plugins/drama.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/drama.py b/plugins/drama.py index 47df5e2..ffe1213 100755 --- a/plugins/drama.py +++ b/plugins/drama.py @@ -1,4 +1,5 @@ -from util import hook, http +from util import hook, http, text +import re api_url = "http://encyclopediadramatica.se/api.php?action=opensearch" ed_url = "http://encyclopediadramatica.se/" @@ -10,6 +11,7 @@ def drama(inp): " the Encyclopedia Dramatica article on ." j = http.get_json(api_url, search=inp) + if not j[1]: return "No results found." article_name = j[1][0].replace(' ', '_').encode('utf8') @@ -17,11 +19,11 @@ def drama(inp): url = ed_url + http.quote(article_name, '') page = http.get_html(url) - for p in page.xpath('//div[@id="bodyContent"]/p'): + for p in page.xpath('//div[@class="mw-content-ltr"]/p'): if p.text_content(): summary = " ".join(p.text_content().splitlines()) - if len(summary) > 300: - summary = summary[:summary.rfind(' ', 0, 300)] + "..." - return "%s :: \x02%s\x02" % (summary, url) + summary = re.sub("\[\d+\]", "", summary) + summary = text.truncate_str(summary, 200) + return "%s :: %s" % (summary, url) return "Unknown Error." From 5e161486ffa151d2be1830ac75792ede803b49de Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 4 Sep 2013 20:30:26 +1200 Subject: [PATCH 2/5] unstandardised that one bit --- plugins/drama.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/drama.py b/plugins/drama.py index ffe1213..6883372 100755 --- a/plugins/drama.py +++ b/plugins/drama.py @@ -19,11 +19,11 @@ def drama(inp): url = ed_url + http.quote(article_name, '') page = http.get_html(url) - for p in page.xpath('//div[@class="mw-content-ltr"]/p'): + for p in page.xpath('//div[@id="bodyContent"]/p'): if p.text_content(): summary = " ".join(p.text_content().splitlines()) summary = re.sub("\[\d+\]", "", summary) - summary = text.truncate_str(summary, 200) + summary = text.truncate_str(summary, 220) return "%s :: %s" % (summary, url) return "Unknown Error." From 3c0ba0bdd2618693e45935425eff4ad345dd2ea5 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 4 Sep 2013 21:28:10 +1200 Subject: [PATCH 3/5] added isup --- plugins/isup.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugins/isup.py diff --git a/plugins/isup.py b/plugins/isup.py new file mode 100644 index 0000000..3d16ccb --- /dev/null +++ b/plugins/isup.py @@ -0,0 +1,28 @@ +import urlparse + +from util import hook, http, urlnorm + + +@hook.command +def isup(inp): + "isup -- uses isup.me to see if a site is up or not" + + # slightly overcomplicated, esoteric URL parsing + scheme, auth, path, query, fragment = urlparse.urlsplit(inp.strip()) + + domain = auth.encode('utf-8') or path.encode('utf-8') + url = urlnorm.normalize(domain, assume_scheme="http") + + try: + soup = http.get_soup('http://isup.me/' + domain) + except http.HTTPError, http.URLError: + return "Could not get status." + + content = soup.find('div').text.strip() + + if "not just you" in content: + return "It's not just you. {} looks \x02\x034down\x02\x0f from here!".format(url) + elif "is up" in content: + return "It's just you. {} is \x02\x033up\x02\x0f.".format(url) + else: + return "Huh? That doesn't look like a site on the interweb." \ No newline at end of file From f85bc3e935f7846808d7161affd08e2a330a61cc Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 4 Sep 2013 22:59:58 +1200 Subject: [PATCH 4/5] unborked --- plugins/core_ctcp.py | 6 +++--- plugins/core_misc.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/core_ctcp.py b/plugins/core_ctcp.py index 7312adf..523a4e4 100755 --- a/plugins/core_ctcp.py +++ b/plugins/core_ctcp.py @@ -4,15 +4,15 @@ from util import hook # CTCP responses @hook.regex(r'^\x01VERSION\x01$') -def ctcp_version(notice=None): +def ctcp_version(inp, notice=None): notice('\x01VERSION: CloudBot - http://git.io/cloudbotirc') @hook.regex(r'^\x01PING\x01$') -def ctcp_ping(notice=None): +def ctcp_ping(inp, notice=None): notice('\x01PING: PONG') @hook.regex(r'^\x01TIME\x01$') -def ctcp_time(notice=None): +def ctcp_time(inp, notice=None): notice('\x01TIME: The time is: %s' % time.strftime("%r", time.localtime())) diff --git a/plugins/core_misc.py b/plugins/core_misc.py index 27c264a..4fb082f 100755 --- a/plugins/core_misc.py +++ b/plugins/core_misc.py @@ -19,7 +19,7 @@ def invite(paraml, conn=None): # Identify to NickServ (or other service) @hook.event('004') -def onjoin(conn=None, bot=None): +def onjoin(paraml, conn=None, bot=None): nickserv_password = conn.conf.get('nickserv_password', '') nickserv_name = conn.conf.get('nickserv_name', 'nickserv') nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY %s') From 99b14bac59f0a7a7142fd2230e70b6817c6ff682 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 4 Sep 2013 23:06:44 +1200 Subject: [PATCH 5/5] Updated CONTRIBUTORS. You are all great! --- CONTRIBUTORS | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9f8a2a3..8810f2f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3,14 +3,21 @@ Thanks to everyone who has contributed to CloudBot! Come in IRC and ping me if I Luke Rogers (lukeroge) Neersighted blha303 -KsaRedFx -urbels cybojenix +KsaRedFx +nathanblaney +thenoodle68 +nasonfish +urbels +puffrfish +Sepero +TheFiZi +mikeleigh Spudstabber frozenMC frdmn -puffrfish -nasonfish + + We are using code from the following projects: ./plugins/mlia.py - https://github.com/infinitylabs/UguuBot