From 5f2ddb7574926540aac453203b9c0892f58397d4 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:34:38 -0500 Subject: [PATCH 01/17] Add files via upload --- __init__.py | 43 ++++++++++++++++++++++++++++++++++ config.py | 29 +++++++++++++++++++++++ plugin.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test.py | 16 +++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 __init__.py create mode 100644 config.py create mode 100644 plugin.py create mode 100644 test.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0709d73 --- /dev/null +++ b/__init__.py @@ -0,0 +1,43 @@ +### +# Copyright (c) 2019 oddluck +# All rights reserved. +# +# +### + +""" +Fun: Uses API to retrieve information +""" + +import supybot +import supybot.world as world + +# Use this for the version of this plugin. You may wish to put a CVS keyword +# in here if you're keeping the plugin in CVS or some similar system. +__version__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.authors.unknown + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' + +from . import config +from . import plugin +from imp import reload +# In case we're being reloaded. +reload(config) +reload(plugin) +# Add more reloads here if you add third-party modules and want them to be +# reloaded when this plugin is reloaded. Don't forget to import them as well! + +if world.testing: + from . import test + +Class = plugin.Class +configure = config.configure + diff --git a/config.py b/config.py new file mode 100644 index 0000000..2c6420e --- /dev/null +++ b/config.py @@ -0,0 +1,29 @@ +### +# Copyright (c) 2019, oddluck +# All rights reserved. +# +# +### + +import supybot.conf as conf +import supybot.registry as registry +try: + from supybot.i18n import PluginInternationalization + _ = PluginInternationalization('Fun') +except: + # Placeholder that allows to run the plugin on a bot + # without the i18n module + _ = lambda x: x + + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # a bool that specifies whether the user identified themself as an advanced + # user or not. You should effect your configuration by manipulating the + # registry as appropriate. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('Fun', True) + + +Advice = conf.registerPlugin('Fun') + diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..750325d --- /dev/null +++ b/plugin.py @@ -0,0 +1,66 @@ +### +# Copyright (c) 2019 oddluck +# All rights reserved. +# +# +### + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks +import supybot.ircmsgs as ircmsgs +import requests + +try: + from supybot.i18n import PluginInternationalization + _ = PluginInternationalization('Weed') +except ImportError: + # Placeholder that allows to run the plugin on a bot + # without the i18n module + _ = lambda x: x + +class Fun(callbacks.Plugin): + """Uses API to retrieve information""" + threaded = True + + def advice(self, irc, msg, args): + """ + Get some advice + """ + + channel = msg.args[0] + data = requests.get("https://api.adviceslip.com/advice").json() + irc.reply(data['slip']['advice']) + + advice = wrap(advice) + + def joke(self, irc, msg, args): + """ + Get a joke + """ + + channel = msg.args[0] + headers = { + 'Accept': 'text/plain', + } + + response = requests.get('https://icanhazdadjoke.com/', headers=headers, verify=False) + + irc.reply(response.text) + + joke = wrap(joke) + + def catfact(self, irc, msg, args): + """ + Get some advice + """ + + channel = msg.args[0] + data = requests.get("https://catfact.ninja/fact").json() + irc.reply(data['fact']) + + catfact = wrap(catfact) + +Class = Fun diff --git a/test.py b/test.py new file mode 100644 index 0000000..8317613 --- /dev/null +++ b/test.py @@ -0,0 +1,16 @@ +### +# Copyright (c) 2019, oddluck +# All rights reserved. +# +# +### + +from supybot.test import * + + +class AdviceTestCase(PluginTestCase): + plugins = ('Fun',) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: + From 217d63211a5749b187a3e007a0ff8b910bd6bb57 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:34:58 -0500 Subject: [PATCH 02/17] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd779a0 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Fun +Limnoria plugin to return random jokes, advice, or cat facts from various APIs From a19b0f207a4aef4433b21543ee119cc5d85e0a68 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:41:10 -0500 Subject: [PATCH 03/17] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd779a0..82bec8e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Fun -Limnoria plugin to return random jokes, advice, or cat facts from various APIs +Limnoria plugin to return a random joke, cat fact, or advice from various APIs + +requires limnoria, python 3, requests From 861fecca81e6640031aa9383a6cd77ffea99a529 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:50:19 -0500 Subject: [PATCH 04/17] add useless facts --- plugin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugin.py b/plugin.py index 750325d..4071d53 100644 --- a/plugin.py +++ b/plugin.py @@ -63,4 +63,15 @@ class Fun(callbacks.Plugin): catfact = wrap(catfact) + def useless(self, irc, msg, args): + """ + Get some advice + """ + + channel = msg.args[0] + data = requests.get("http://randomuselessfact.appspot.com/random.json").json() + irc.reply(data['text']) + + useless = wrap(useless) + Class = Fun From bb73a0b8842f8a99fee291c0e2087f76c5272eb5 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:50:51 -0500 Subject: [PATCH 05/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82bec8e..c210122 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # Fun -Limnoria plugin to return a random joke, cat fact, or advice from various APIs +Limnoria plugin to return a random joke, cat fact, useless fact, or advice from various APIs requires limnoria, python 3, requests From e354ae09d47ab0b10e61fe58d82ea392d7fc7a93 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:54:13 -0500 Subject: [PATCH 06/17] Update plugin.py --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 4071d53..4e4ec21 100644 --- a/plugin.py +++ b/plugin.py @@ -69,7 +69,7 @@ class Fun(callbacks.Plugin): """ channel = msg.args[0] - data = requests.get("http://randomuselessfact.appspot.com/random.json").json() + data = requests.get("http://randomuselessfact.appspot.com/random.json?language=en").json() irc.reply(data['text']) useless = wrap(useless) From 16afd2c7568ac2c2bf983467e03c064c15ba4740 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 21:56:12 -0500 Subject: [PATCH 07/17] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c210122..e6b1908 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Fun Limnoria plugin to return a random joke, cat fact, useless fact, or advice from various APIs +commands: advice, cat fact, joke, useless + requires limnoria, python 3, requests From 0b32948c27c903a4a52cdaacf9aaa4701fee7a8d Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:16:42 -0500 Subject: [PATCH 08/17] add corp. buzzword generator --- plugin.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugin.py b/plugin.py index 4e4ec21..e255648 100644 --- a/plugin.py +++ b/plugin.py @@ -26,7 +26,7 @@ class Fun(callbacks.Plugin): threaded = True def advice(self, irc, msg, args): - """ + """ Get some advice """ @@ -37,7 +37,7 @@ class Fun(callbacks.Plugin): advice = wrap(advice) def joke(self, irc, msg, args): - """ + """ Get a joke """ @@ -53,8 +53,8 @@ class Fun(callbacks.Plugin): joke = wrap(joke) def catfact(self, irc, msg, args): - """ - Get some advice + """ + Cat fact """ channel = msg.args[0] @@ -62,10 +62,10 @@ class Fun(callbacks.Plugin): irc.reply(data['fact']) catfact = wrap(catfact) - + def useless(self, irc, msg, args): - """ - Get some advice + """ + Useless fact """ channel = msg.args[0] @@ -73,5 +73,14 @@ class Fun(callbacks.Plugin): irc.reply(data['text']) useless = wrap(useless) + + def buzz(self, irc, msg, args): + """ + Corporate buzzord generator + """ + channel = msg.args[0] + data = requests.get("https://corporatebs-generator.sameerkumar.website").json() + irc.reply(data['phrase']) + buzz = wrap(buzz) Class = Fun From 0244ada92ccf4bd855ce9cbb59c07940cc58113d Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:17:15 -0500 Subject: [PATCH 09/17] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6b1908..dc61132 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fun -Limnoria plugin to return a random joke, cat fact, useless fact, or advice from various APIs +Limnoria plugin to return a random joke, cat fact, useless fact, corporate buzzwords, or advice from various APIs -commands: advice, cat fact, joke, useless +commands: advice, buzz, cat fact, joke, useless requires limnoria, python 3, requests From 576f533976d77caf4e96be38db2a0c03fb6a74ee Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:39:14 -0500 Subject: [PATCH 10/17] add startup idea generator --- plugin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugin.py b/plugin.py index e255648..5c85e6c 100644 --- a/plugin.py +++ b/plugin.py @@ -83,4 +83,14 @@ class Fun(callbacks.Plugin): irc.reply(data['phrase']) buzz = wrap(buzz) + def startup(self, irc, msg, args): + """ + Startup idea generator + """ + channel = msg.args[0] + data = requests.get("http://itsthisforthat.com/api.php?json").json() + response = "So, Basically, It\'s Like A {0} for {1}".format(data['this'], data['that']) + irc.reply(response) + startup = wrap(startup) + Class = Fun From 9d22cda332f38073c4558e140909384a9edd6f03 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:39:34 -0500 Subject: [PATCH 11/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc61132..209e886 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Fun -Limnoria plugin to return a random joke, cat fact, useless fact, corporate buzzwords, or advice from various APIs +Limnoria plugin to return a random joke, cat fact, useless fact, corporate buzzwords, startup idea, or advice from various APIs commands: advice, buzz, cat fact, joke, useless From 0945cb7354931804cebdb2f5468bd4f974c64e51 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:39:47 -0500 Subject: [PATCH 12/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 209e886..05008eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fun Limnoria plugin to return a random joke, cat fact, useless fact, corporate buzzwords, startup idea, or advice from various APIs -commands: advice, buzz, cat fact, joke, useless +commands: advice, buzz, cat fact, joke, startup, useless requires limnoria, python 3, requests From 881ce8284b24a66e5bf921cfb77ad4766f10fbf4 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Thu, 7 Feb 2019 22:46:07 -0500 Subject: [PATCH 13/17] Update plugin.py --- plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 5c85e6c..058b749 100644 --- a/plugin.py +++ b/plugin.py @@ -85,11 +85,15 @@ class Fun(callbacks.Plugin): def startup(self, irc, msg, args): """ - Startup idea generator + Startup generator """ channel = msg.args[0] data = requests.get("http://itsthisforthat.com/api.php?json").json() - response = "So, Basically, It\'s Like A {0} for {1}".format(data['this'], data['that']) + vowels = ('a','e','i','o','u','A','E','I','O','U') + if data['this'].startswith(vowels): + response = "So, Basically, It\'s Like An {0} for {1}".format(data['this'], data['that']) + else: + response = "So, Basically, It\'s Like A {0} for {1}".format(data['this'], data['that']) irc.reply(response) startup = wrap(startup) From 7c896324ab4a02bed132832cd76d98a01c2375c9 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Fri, 8 Feb 2019 11:15:09 -0500 Subject: [PATCH 14/17] Update plugin.py --- plugin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugin.py b/plugin.py index 058b749..7c5d404 100644 --- a/plugin.py +++ b/plugin.py @@ -43,12 +43,10 @@ class Fun(callbacks.Plugin): channel = msg.args[0] headers = { - 'Accept': 'text/plain', + 'Accept': 'application/json', } - - response = requests.get('https://icanhazdadjoke.com/', headers=headers, verify=False) - - irc.reply(response.text) + data = requests.get('https://icanhazdadjoke.com/', headers=headers).json() + irc.reply(data['joke']) joke = wrap(joke) From 0a7c3199c34f0a4d6344ecd37edf3fc3f0d7638c Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Sat, 9 Feb 2019 14:05:52 -0500 Subject: [PATCH 15/17] Update plugin.py --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 7c5d404..58f588b 100644 --- a/plugin.py +++ b/plugin.py @@ -46,7 +46,7 @@ class Fun(callbacks.Plugin): 'Accept': 'application/json', } data = requests.get('https://icanhazdadjoke.com/', headers=headers).json() - irc.reply(data['joke']) + irc.reply(data['joke'].replace('\n', '').replace('\r', '').replace('\t', '')) joke = wrap(joke) From eca3d3eed7e8790885d1b5f33b39062c9b0518a0 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Wed, 13 Feb 2019 18:14:44 -0500 Subject: [PATCH 16/17] add insult generator --- plugin.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 58f588b..3b11bb2 100644 --- a/plugin.py +++ b/plugin.py @@ -12,6 +12,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks import supybot.ircmsgs as ircmsgs import requests +import html try: from supybot.i18n import PluginInternationalization @@ -80,7 +81,7 @@ class Fun(callbacks.Plugin): data = requests.get("https://corporatebs-generator.sameerkumar.website").json() irc.reply(data['phrase']) buzz = wrap(buzz) - + def startup(self, irc, msg, args): """ Startup generator @@ -94,5 +95,15 @@ class Fun(callbacks.Plugin): response = "So, Basically, It\'s Like A {0} for {1}".format(data['this'], data['that']) irc.reply(response) startup = wrap(startup) + + def insult(self, irc, msg, args): + """ + Insult generator. + """ + channel = msg.args[0] + data = requests.get("https://insult.mattbas.org/api/en/insult.json").json() + irc.reply(data['insult']) + insult = wrap(insult) + Class = Fun From 13f801e3c428fa61c780106d02c8dd7c1e348e79 Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Wed, 13 Feb 2019 18:14:56 -0500 Subject: [PATCH 17/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05008eb..6f00f80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fun Limnoria plugin to return a random joke, cat fact, useless fact, corporate buzzwords, startup idea, or advice from various APIs -commands: advice, buzz, cat fact, joke, startup, useless +commands: advice, buzz, cat fact, joke, startup, useless, insult requires limnoria, python 3, requests