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 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') diff --git a/plugins/drama.py b/plugins/drama.py index 9d07e74..b6bf77d 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') @@ -20,8 +22,8 @@ def drama(inp): for p in page.xpath('//div[@id="bodyContent"]/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, 220) + return "%s :: %s" % (summary, url) return "Unknown Error." 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