mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-26 13:01:09 -05:00
Add 'Fun/' from commit '13f801e3c428fa61c780106d02c8dd7c1e348e79'
git-subtree-dir: Fun git-subtree-mainline: 2f4f636369fae0d68e4dfe7b843d1d2fb048dab7 git-subtree-split: 13f801e3c428fa61c780106d02c8dd7c1e348e79
This commit is contained in:
commit
00a3eda667
6
Fun/README.md
Normal file
6
Fun/README.md
Normal file
@ -0,0 +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, insult
|
||||||
|
|
||||||
|
requires limnoria, python 3, requests
|
43
Fun/__init__.py
Normal file
43
Fun/__init__.py
Normal file
@ -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
|
||||||
|
|
29
Fun/config.py
Normal file
29
Fun/config.py
Normal file
@ -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')
|
||||||
|
|
109
Fun/plugin.py
Normal file
109
Fun/plugin.py
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
###
|
||||||
|
# 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
|
||||||
|
import html
|
||||||
|
|
||||||
|
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': 'application/json',
|
||||||
|
}
|
||||||
|
data = requests.get('https://icanhazdadjoke.com/', headers=headers).json()
|
||||||
|
irc.reply(data['joke'].replace('\n', '').replace('\r', '').replace('\t', ''))
|
||||||
|
|
||||||
|
joke = wrap(joke)
|
||||||
|
|
||||||
|
def catfact(self, irc, msg, args):
|
||||||
|
"""
|
||||||
|
Cat fact
|
||||||
|
"""
|
||||||
|
|
||||||
|
channel = msg.args[0]
|
||||||
|
data = requests.get("https://catfact.ninja/fact").json()
|
||||||
|
irc.reply(data['fact'])
|
||||||
|
|
||||||
|
catfact = wrap(catfact)
|
||||||
|
|
||||||
|
def useless(self, irc, msg, args):
|
||||||
|
"""
|
||||||
|
Useless fact
|
||||||
|
"""
|
||||||
|
|
||||||
|
channel = msg.args[0]
|
||||||
|
data = requests.get("http://randomuselessfact.appspot.com/random.json?language=en").json()
|
||||||
|
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)
|
||||||
|
|
||||||
|
def startup(self, irc, msg, args):
|
||||||
|
"""
|
||||||
|
Startup generator
|
||||||
|
"""
|
||||||
|
channel = msg.args[0]
|
||||||
|
data = requests.get("http://itsthisforthat.com/api.php?json").json()
|
||||||
|
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)
|
||||||
|
|
||||||
|
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
|
16
Fun/test.py
Normal file
16
Fun/test.py
Normal file
@ -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:
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user