Merge pull request #21 from bobloy/snapons-develop

Snapons develop
readme_updates
bobloy 6 years ago committed by GitHub
commit ccc2d46ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,14 +14,19 @@ Cog Function
| hangman | **Alpha** | <details><summary>Play a game of hangman</summary>Some visual glitches and needs more customization</details> | | hangman | **Alpha** | <details><summary>Play a game of hangman</summary>Some visual glitches and needs more customization</details> |
| howdoi | **Incomplete** | <details><summary>Ask coding questions and get results from StackExchange</summary>Not yet functional</details> | | howdoi | **Incomplete** | <details><summary>Ask coding questions and get results from StackExchange</summary>Not yet functional</details> |
| leaver | **Alpha** | <details><summary>Send a message in a channel when a user leaves the server</summary>Just released, please report bugs</details> | | leaver | **Alpha** | <details><summary>Send a message in a channel when a user leaves the server</summary>Just released, please report bugs</details> |
| lovecalculator | **Alpha** | <details><summary>Calculate the love between two users</summary>[Snap-Ons] Just updated to V3</details> |
| lseen | **Alpha** | <details><summary>Track when a member was last online</summary>Alpha release, please report bugs</details> | | lseen | **Alpha** | <details><summary>Track when a member was last online</summary>Alpha release, please report bugs</details> |
| qrinvite | **Alpha** | <details><summary>Create a QR code invite for the server</summary>Alpha release, please report any bugs</details> |
| reactrestrict | **Alpha** | <details><summary>Removes reactions by role per channel</summary>A bit clunky, but functional</details> | | reactrestrict | **Alpha** | <details><summary>Removes reactions by role per channel</summary>A bit clunky, but functional</details> |
| recyclingplant | **Alpha** | <details><summary>Work at a recycling plant</summary>[Snap-Ons] Just updated to V3</details> |
| rpsls | **Alpha** | <details><summary>Play Rock-Paper-Scissors-Lizard-Spock</summary>[Snap-Ons] Just updated to V3</details> |
| sayurl | **Alpha** | <details><summary>Convert any URL into text and post to discord</summary>No error checking and pretty spammy</details> | | sayurl | **Alpha** | <details><summary>Convert any URL into text and post to discord</summary>No error checking and pretty spammy</details> |
| scp | **Alpha** | <details><summary>Look-up SCP articles</summary>[Snap-Ons] Just updated to V3</details> |
| secrethitler | **Incomplete** | <details><summary>Play the Secret Hitler game</summary>Concept, no work done yet</details> | | secrethitler | **Incomplete** | <details><summary>Play the Secret Hitler game</summary>Concept, no work done yet</details> |
| stealemoji | **Alpha** | <details><summary>Steals any custom emoji it sees in a reaction</summary>Some planned upgrades for server generation</details> | | stealemoji | **Alpha** | <details><summary>Steals any custom emoji it sees in a reaction</summary>Some planned upgrades for server generation</details> |
| timerole | **Alpha** | <details><summary>Add roles to members after specified time on the server</summary>Upgraded from V2, please report any bugs</details> | | timerole | **Alpha** | <details><summary>Add roles to members after specified time on the server</summary>Upgraded from V2, please report any bugs</details> |
| tts | **Alpha** | <details><summary>Send a Text-to-Speech message as an uploaded mp3</summary>Alpha release, please report any bugs</details> | | tts | **Alpha** | <details><summary>Send a Text-to-Speech message as an uploaded mp3</summary>Alpha release, please report any bugs</details> |
| qrinvite | **Alpha** | <details><summary>Create a QR code invite for the server</summary>Alpha release, please report any bugs</details> | | unicode | **Alpha** | <details><summary>Encode and Decode unicode characters</summary>[Snap-Ons] Just updated to V3</details> |
| werewolf | **Alpha** | <details><summary>Play the classic party game Werewolf within discord</summary>Another massive project currently being developed, will be fully customizable</details> | | werewolf | **Alpha** | <details><summary>Play the classic party game Werewolf within discord</summary>Another massive project currently being developed, will be fully customizable</details> |

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

@ -0,0 +1,23 @@
{
"author": [
"Bobloy",
"SnappyDragon"
],
"bot_version": [
3,
0,
0
],
"description": "Calculate the love percentage for two users",
"hidden": false,
"install_msg": "Thank you for installing LoveCalculator. Love is in the air.",
"requirements": [
"beautifulsoup4"
],
"short": "Calculate love percentage",
"tags": [
"bobloy",
"fun",
"love"
]
}

@ -0,0 +1,44 @@
import aiohttp
import discord
from bs4 import BeautifulSoup
from redbot.core import commands
class LoveCalculator:
"""Calculate the love percentage for two users!"""
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=['lovecalc'])
async def lovecalculator(self, ctx: commands.Context, lover: discord.Member, loved: discord.Member):
"""Calculate the love percentage!"""
x = lover.display_name
y = loved.display_name
url = 'https://www.lovecalculator.com/love.php?name1={}&name2={}'.format(x.replace(" ", "+"),
y.replace(" ", "+"))
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
soup_object = BeautifulSoup(await response.text(), "html.parser")
try:
description = soup_object.find('div', attrs={'class': 'result score'}).get_text().strip()
except:
description = 'Dr. Love is busy right now'
try:
z = description[:2]
z = int(z)
if z > 50:
emoji = ''
else:
emoji = '💔'
title = 'Dr. Love says that the love percentage for {} and {} is:'.format(x, y)
except:
emoji = ''
title = 'Dr. Love has left a note for you.'
description = emoji + ' ' + description + ' ' + emoji
em = discord.Embed(title=title, description=description, color=discord.Color.red())
await ctx.send(embed=em)

@ -0,0 +1,9 @@
from redbot.core import data_manager
from .recyclingplant import RecyclingPlant
def setup(bot):
plant = RecyclingPlant(bot)
data_manager.load_bundled_data(plant, __file__)
bot.add_cog(plant)

@ -0,0 +1,204 @@
{
"can": [
{
"object": "Apple Core",
"action": "trash"
},
{
"object": "Paper Cup",
"action": "recycle"
},
{
"object": "Banana Peel",
"action": "trash"
},
{
"object": "Paper Bag",
"action": "recycle"
},
{
"object": "Old Taco",
"action": "trash"
},
{
"object": "Newspaper",
"action": "recycle"
},
{
"object": "Chewed Gum",
"action": "trash"
},
{
"object": "Polythene Bag",
"action": "recycle"
},
{
"object": "Rotten Eggs",
"action": "trash"
},
{
"object": "Outdated Telephone Directory",
"action": "recycle"
},
{
"object": "Stale Bread",
"action": "trash"
},
{
"object": "Used Notebook",
"action": "recycle"
},
{
"object": "Sour Milk",
"action": "trash"
},
{
"object": "Old Textbook",
"action": "recycle"
},
{
"object": "Week-Old Sandwich",
"action": "trash"
},
{
"object": "Paper Ball",
"action": "recycle"
},
{
"object": "Leftovers",
"action": "trash"
},
{
"object": "Toy Car",
"action": "recycle"
},
{
"object": "Fish Bones",
"action": "trash"
},
{
"object": "Superhero Costume",
"action": "recycle"
},
{
"object": "Dirty Diaper",
"action": "trash"
},
{
"object": "Silcone Mould",
"action": "recycle"
},
{
"object": "Mouldy Broccoli",
"action": "trash"
},
{
"object": "TV Remote",
"action": "recycle"
},
{
"object": "Withered Rose Bouquet",
"action": "trash"
},
{
"object": "Paper Plate",
"action": "recycle"
},
{
"object": "Slimy Bacon",
"action": "trash"
},
{
"object": "Folders",
"action": "recycle"
},
{
"object": "Fly Agaric Mushrooms",
"action": "trash"
},
{
"object": "Phone case",
"action": "recycle"
},
{
"object": "Napkins",
"action": "trash"
},
{
"object": "Broken Dualshock 4 Controller",
"action": "recycle"
},
{
"object": "Wax Paper",
"action": "trash"
},
{
"object": "iPad",
"action": "recycle"
},
{
"object": "Paint Can",
"action": "trash"
},
{
"object": "Glass Bottle",
"action": "recycle"
},
{
"object": "Light Bulb",
"action": "trash"
},
{
"object": "Nintendo 3DS",
"action": "recycle"
},
{
"object": "Styrofoam Container",
"action": "trash"
},
{
"object": "Flash Cards",
"action": "recycle"
},
{
"object": "Motor Oil Can",
"action": "trash"
},
{
"object": "Candy Wrapper",
"action": "recycle"
},
{
"object": "Waxed Cardboard",
"action": "trash"
},
{
"object": "Empty Bottle",
"action": "recycle"
},
{
"object": "Used Toilet Paper",
"action": "trash"
},
{
"object": "Outdated Calendar",
"action": "recycle"
},
{
"object": "Ceramic Mug",
"action": "trash"
},
{
"object": "Plastic Cup",
"action": "recycle"
},
{
"object": "Gift Wrapping",
"action": "trash"
},
{
"object": "Soda Bottle",
"action": "recycle"
}
]
}

@ -0,0 +1,21 @@
{
"author": [
"Bobloy",
"SnappyDragon"
],
"bot_version": [
3,
0,
0
],
"description": "Apply for a job at the recycling plant! Sort out the garbage!",
"hidden": false,
"install_msg": "Thank you for installing RecyclingPlant. Start recycling today with `[p]recyclingplant`",
"requirements": [],
"short": "Apply for a job at the recycling plant!",
"tags": [
"bobloy",
"environment",
"games"
]
}

@ -0,0 +1,67 @@
import asyncio
import json
import random
from redbot.core import bank
from redbot.core import commands
from redbot.core.data_manager import cog_data_path
class RecyclingPlant:
"""Apply for a job at the recycling plant!"""
def __init__(self, bot):
self.bot = bot
self.path = str(cog_data_path(self)).replace('\\', '/')
self.junk_path = self.path + "/bundled_data/junk.json"
with open(self.junk_path) as json_data:
self.junk = json.load(json_data)
@commands.command(aliases=["recycle"])
async def recyclingplant(self, ctx: commands.Context):
"""Apply for a job at the recycling plant!"""
x = 0
reward = 0
await ctx.send(
'{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.'.format(
ctx.author.display_name))
while x in range(0, 10):
used = random.choice(self.junk['can'])
if used['action'] == 'trash':
opp = 'recycle'
else:
opp = 'trash'
await ctx.send('``{}``! Will {} ``trash`` it or ``recycle`` it?'.format(used['object'],
ctx.author.display_name))
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
try:
answer = await self.bot.wait_for('message', timeout=120, check=check)
except asyncio.TimeoutError:
answer = None
if answer is None:
await ctx.send('``{}`` fell down the conveyor belt to be sorted again!'.format(used['object']))
elif answer.content.lower().strip() == used['action']:
await ctx.send(
'Congratulations! You put ``{}`` down the correct chute! (**+50**)'.format(used['object']))
reward = reward + 50
x += 1
elif answer.content.lower().strip() == opp:
await ctx.send('{}, you little brute, you put it down the wrong chute! (**-50**)'.format(
ctx.author.display_name))
reward = reward - 50
elif answer.content.lower().strip() == 'exit':
await ctx.send('{} has been relived of their duty.'.format(ctx.author.display_name))
break
else:
await ctx.send('``{}`` fell down the conveyor belt to be sorted again!'.format(used['object']))
else:
if reward > 0:
bank.deposit_credits(ctx.author, reward)
await ctx.send(
'{} been given **{} {}s** for your services.'.format(ctx.author.display_name, reward,
bank.get_currency_name(ctx.guild)))

@ -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(list(self.weaknesses.keys()))
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 4999.
"""
# Thanks Shigbeard and Redjumpman for helping me!
if 0 < num <= 4999:
msg = "http://www.scp-wiki.net/scp-{:03}".format(num)
c = discord.Color.green()
else:
msg = "You must specify a number between 1 and 4999."
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,5 @@
from .unicode import Unicode
def setup(bot):
bot.add_cog(Unicode(bot))

@ -0,0 +1,21 @@
{
"author": [
"Bobloy",
"SnappyDragon"
],
"bot_version": [
3,
0,
0
],
"description": "Encode/Decode Unicode characters!",
"hidden": false,
"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",
"requirements": [],
"short": "Encode/Decode Unicode characters!",
"tags": [
"bobloy",
"utility",
"tools"
]
}

@ -0,0 +1,49 @@
import codecs as c
import discord
from redbot.core 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, ctx):
"""Encode/Decode a Unicode character."""
if ctx.invoked_subcommand is None:
pass
@unicode.command()
async def decode(self, ctx: commands.Context, 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 ctx.send(embed=em)
@unicode.command()
async def encode(self, ctx:commands.Context, 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 ctx.send(embed=em)
Loading…
Cancel
Save