[Snap-Ons] More converted cogs

pull/21/head
Bobloy 7 years ago
parent 093a650dbd
commit 4cb531ab87

@ -10,9 +10,9 @@
], ],
"description": "Apply for a job at the recycling plant! Sort out the garbage!", "description": "Apply for a job at the recycling plant! Sort out the garbage!",
"hidden": false, "hidden": false,
"install_msg": "Thank you for installing LoveCalculator. Stary recycling today!", "install_msg": "Thank you for installing RecyclingPlant. Start recycling today with `[p]recyclingplant`",
"requirements": [], "requirements": [],
"short": "ply for a job at the recycling plant!", "short": "Apply for a job at the recycling plant!",
"tags": [ "tags": [
"bobloy", "bobloy",
"environment", "environment",

@ -18,7 +18,7 @@ class RecyclingPlant:
with open(self.junk_path) as json_data: with open(self.junk_path) as json_data:
self.junk = json.load(json_data) self.junk = json.load(json_data)
@commands.command() @commands.command(aliases=["recycle"])
async def recyclingplant(self, ctx: commands.Context): async def recyclingplant(self, ctx: commands.Context):
"""Apply for a job at the recycling plant!""" """Apply for a job at the recycling plant!"""
x = 0 x = 0

@ -0,0 +1,5 @@
from .rpsls import RPSLS
def setup(bot):
bot.add_cog(RPSLS(bot))

@ -0,0 +1,21 @@
{
"author": [
"Bobloy",
"SnappyDragon"
],
"bot_version": [
3,
0,
0
],
"description": "Play Rock Papers Scissor Lizard Spock by Sam Kass in Discord!",
"hidden": false,
"install_msg": "Thank you for installing RPSLP. Get started with `[p]rpsls`",
"requirements": [],
"short": "Play Rock Papers Scissor Lizard Spock in Discord!",
"tags": [
"bobloy",
"star trek",
"games"
]
}

@ -0,0 +1,90 @@
import asyncio
import random
import discord
from redbot.core import commands
class RPSLS:
"""Play Rock Paper Scissors Lizard Spock."""
weaknesses = {
"rock": [
"paper",
"spock"
],
"paper": [
"scissors",
"lizard"
],
"scissors": [
"spock",
"rock"
],
"lizard": [
"scissors",
"rock"
],
"spock": [
"paper",
"lizard"
]
}
def __init__(self, bot):
self.bot = bot
@commands.command()
async def rpsls(self, ctx: commands.Context, choice: str):
"""
Play Rock Paper Scissors Lizard Spock by Sam Kass in Discord!
Rules:
Scissors cuts Paper
Paper covers Rock
Rock crushes Lizard
Lizard poisons Spock
Spock smashes Scissors
Scissors decapitates Lizard
Lizard eats Paper
Paper disproves Spock
Spock vaporizes Rock
And as it has always Rock crushes Scissors
"""
player_choice = choice.lower()
player_emote = self.get_emote(player_choice)
if player_emote is None:
await ctx.maybe_send_embed("Invalid Choice")
return
bot_choice = random.choice(self.weaknesses)
bot_emote = self.get_emote(bot_choice)
message = '{} vs. {}, who will win?'.format(player_emote, bot_emote)
em = discord.Embed(description=message, color=discord.Color.blue())
await ctx.send(embed=em)
await asyncio.sleep(2)
if player_choice in self.weaknesses[bot_choice]:
message = 'You win! :sob:'
em_color = discord.Color.green()
elif bot_choice in self.weaknesses[player_choice]:
message = 'I win! :smile:'
em_color = discord.Color.red()
else:
message = 'It\'s a draw! :neutral_face:'
em_color = discord.Color.blue()
em = discord.Embed(description=message, color=em_color)
await ctx.send(embed=em)
def get_emote(self, choice):
if choice == 'rock':
emote = ':moyai:'
elif choice == 'spock':
emote = ':vulcan:'
elif choice == 'paper':
emote = ':page_facing_up:'
elif choice in ['scissors', 'lizard']:
emote = ':{}:'.format(choice)
else:
emote = None
return emote

@ -0,0 +1,5 @@
from .scp import SCP
def setup(bot):
bot.add_cog(SCP(bot))

@ -0,0 +1,20 @@
{
"author": [
"Bobloy",
"SnappyDragon"
],
"bot_version": [
3,
0,
0
],
"description": "Look up SCP articles. Warning: Some of them may be too creepy or gruesome.",
"hidden": false,
"install_msg": "You are now connected to the SCP database. You may now proceed to access the data using `[p]help SCP`",
"requirements": [],
"short": "Look up SCP articles.",
"tags": [
"bobloy",
"gruesom"
]
}

@ -0,0 +1,116 @@
import discord
from redbot.core import commands
class SCP:
"""Look up SCP articles. Warning: Some of them may be too creepy or gruesome."""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def scp(self, ctx: commands.Context, num: int):
"""Look up SCP articles.
Warning: Some of them may be too creepy or gruesome.
Reminder: You must specify a number between 1 and 3999.
"""
# Thanks Shigbeard and Redjumpman for helping me!
if 0 < num <= 3999:
msg = "http://www.scp-wiki.net/scp-{:03}".format(num)
c = discord.Color.green()
else:
msg = "You must specify a number between 1 and 3999."
c = discord.Color.red()
if ctx.embed_requested():
await ctx.send(embed=discord.Embed(description=msg, color=c))
else:
await ctx.maybe_send_embed(msg)
@commands.command()
async def scpj(self, ctx: commands.Context, joke: str):
"""Look up SCP-Js.
Reminder: Enter the correct name or else the resultant page will be invalid.
Use 001, etc. in case of numbers less than 100.
"""
msg = "http://www.scp-wiki.net/scp-{}-j".format(joke)
await ctx.maybe_send_embed(msg)
@commands.command()
async def scparc(self, ctx: commands.Context, num: int):
"""Look up SCP archives.
Warning: Some of them may be too creepy or gruesome."""
valid_archive = (
13, 48, 51, 89, 91, 112, 132, 138, 157, 186, 232, 234,
244, 252, 257, 338, 356, 361, 400, 406, 503, 515, 517,
578, 728, 744, 776, 784, 837, 922, 987, 1023)
if num in valid_archive:
msg = "http://www.scp-wiki.net/scp-{:03}-arc".format(num)
c = discord.Color.green()
em = discord.Embed(description=msg, color=c)
else:
ttl = "You must specify a valid archive number."
msg = "{}".format(valid_archive)
c = discord.Color.red()
em = discord.Embed(title=ttl, description=msg, color=c)
if ctx.embed_requested():
await ctx.send(embed=em)
else:
await ctx.maybe_send_embed(msg)
@commands.command()
async def scpex(self, ctx: commands.Context, num: int):
"""Look up explained SCP articles.
Warning: Some of them may be too creepy or gruesome.
"""
valid_archive = (711, 920, 1841, 1851, 1974, 2600, 4023, 8900)
if num in valid_archive:
msg = "http://www.scp-wiki.net/scp-{:03}-ex".format(num)
c = discord.Color.green()
em = discord.Embed(description=msg, color=c)
else:
ttl = "You must specify a valid archive number."
msg = "{}".format(valid_archive)
c = discord.Color.red()
em = discord.Embed(title=ttl, description=msg, color=c)
if ctx.embed_requested():
await ctx.send(embed=em)
else:
await ctx.maybe_send_embed(msg)
@commands.command()
async def anomalousitems(self, ctx: commands.Context):
"""Look through the log of anomalous items."""
msg = "http://www.scp-wiki.net/log-of-anomalous-items"
await ctx.maybe_send_embed(msg)
@commands.command()
async def extranormalevents(self, ctx: commands.Context):
"""Look through the log of extranormal events."""
msg = "http://www.scp-wiki.net/log-of-extranormal-events"
await ctx.maybe_send_embed(msg)
@commands.command()
async def unexplainedlocations(self, ctx: commands.Context):
"""Look through the log of unexplained locations."""
msg = "http://www.scp-wiki.net/log-of-unexplained-locations"
await ctx.maybe_send_embed(msg)
def setup(bot):
bot.add_cog(SCP(bot))

@ -0,0 +1,11 @@
{
"AUTHOR": "SnappyDragon",
"INSTALL_MSG": "\u0048\u0065\u006c\u006c\u006f\u0021 \u0054\u0068\u0069\u0073 \u006d\u0065\u0073\u0073\u0061\u0067\u0065 \u0077\u0061\u0073 \u0077\u0072\u0069\u0074\u0074\u0065\u006e \u0069\u006e \u0055\u004e\u0049\u0043\u004f\u0044\u0045\u002e",
"NAME": "Unicode",
"SHORT": "Encode/Decode Unicode characters!",
"DESCRIPTION": "Encode/Decode a Unicode character!",
"TAGS": [
"utility",
"utlities"
]
}

@ -0,0 +1,53 @@
import codecs as c
import discord
from discord.ext import commands
class Unicode:
"""Encode/Decode Unicode characters!"""
def __init__(self, bot):
self.bot = bot
@commands.group(name='unicode', pass_context=True)
async def unicode(self, context):
"""Encode/Decode a Unicode character."""
if context.invoked_subcommand is None:
await self.bot.send_cmd_help(context)
@unicode.command()
async def decode(self, character):
"""Decode a Unicode character."""
try:
data = 'U+{:04X}'.format(ord(character[0]))
color = discord.Color.green()
except ValueError:
data = '<unknown>'
color = discord.Color.red()
em = discord.Embed(title=character, description=data, color=color)
await self.bot.say(embed=em)
@unicode.command()
async def encode(self, character):
"""Encode an Unicode character."""
try:
if character[:2] == '\\u':
data = repr(c.decode(character, 'unicode-escape'))
data = data.strip("'")
color = discord.Color.green()
elif character[:2] == 'U+':
data = chr(int(character.lstrip('U+'), 16))
color = discord.Color.green()
else:
data = '<unknown>'
color = discord.Color.red()
except ValueError:
data = '<unknown>'
color = discord.Color.red()
em = discord.Embed(title=character, description=data, color=color)
await self.bot.say(embed=em)
def setup(bot):
bot.add_cog(Unicode(bot))
Loading…
Cancel
Save