From 87ed0e8e8ff03754d848e3370868c50612da45dc Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Wed, 1 Apr 2009 17:09:06 -0600 Subject: [PATCH] bible plugin (for victor <3) --- plugins/bible.py | 22 ++++++++++++++++++++++ plugins/sieve.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 plugins/bible.py diff --git a/plugins/bible.py b/plugins/bible.py new file mode 100644 index 0000000..bc6b8e4 --- /dev/null +++ b/plugins/bible.py @@ -0,0 +1,22 @@ +import urllib + +import hook + +@hook.command('god') +@hook.command +def bible(inp): + base_url = 'http://www.esvapi.org/v2/rest/passageQuery?key=IP&' \ + 'output-format=plain-text&include-heading-horizontal-lines&' \ + 'include-headings=false&include-passage-horizontal-lines=false&' \ + 'include-passage-references=false&include-short-copyright=false&' \ + 'include-footnotes=false&line-length=0&passage=' + + text = urllib.urlopen(base_url + urllib.quote(inp)).read() + + text = ' '.join(text.split()) + + if len(text) > 400: + text = text[:text.rfind(' ', 0, 400)] + '...' + + return text + diff --git a/plugins/sieve.py b/plugins/sieve.py index aea4124..a240b66 100644 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -21,7 +21,7 @@ def sieve_suite(bot, input, func, args): if input.command == 'INVITE': print func, hook - input.re = re.match(hook, input.msg) + input.re = re.match(hook, input.msg, flags=re.I) if input.re is None: return None