aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-04-03 12:04:18 +1000
committerGravatar GitHub <[email protected]>2019-04-03 12:04:18 +1000
commit8c3963e846d18d57ced41bf947848c4ede93b31c (patch)
treef2912a7bb063b90834abbc7cdc75b72ff585c7b0
parentMerge pull request #181 from RohanRadia/master (diff)
parentadd `commands.Cog` (diff)
Merge pull request #141 from Suhail6inkling/spooky_rating
Spooky Rating
-rw-r--r--bot/resources/halloween/spooky_rating.json47
-rw-r--r--bot/resources/halloween/spookyrating/baby.jpegbin0 -> 110346 bytes
-rw-r--r--bot/resources/halloween/spookyrating/candle.jpegbin0 -> 45981 bytes
-rw-r--r--bot/resources/halloween/spookyrating/clown.jpegbin0 -> 53035 bytes
-rw-r--r--bot/resources/halloween/spookyrating/costume.jpegbin0 -> 88629 bytes
-rw-r--r--bot/resources/halloween/spookyrating/devil.jpegbin0 -> 336208 bytes
-rw-r--r--bot/resources/halloween/spookyrating/ghost.jpegbin0 -> 29635 bytes
-rw-r--r--bot/resources/halloween/spookyrating/jackolantern.jpegbin0 -> 17598 bytes
-rw-r--r--bot/resources/halloween/spookyrating/necromancer.jpegbin0 -> 139672 bytes
-rw-r--r--bot/resources/halloween/spookyrating/tiger.jpegbin0 -> 52851 bytes
-rw-r--r--bot/seasons/halloween/spookyrating.py68
11 files changed, 115 insertions, 0 deletions
diff --git a/bot/resources/halloween/spooky_rating.json b/bot/resources/halloween/spooky_rating.json
new file mode 100644
index 00000000..1815befc
--- /dev/null
+++ b/bot/resources/halloween/spooky_rating.json
@@ -0,0 +1,47 @@
+{
+ "-1": {
+ "title": "\uD83D\uDD6F You're not scarin' anyone \uD83D\uDD6F",
+ "text": "No matter what you say or do, nobody even flinches when you try to scare them. Was your costume this year only a white sheet with holes for eyes? Or did you even bother with a costume at all? Either way, don't expect too many treats when going from door-to-door.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/candle.jpeg"
+ },
+ "5": {
+ "title": "\uD83D\uDC76 Like taking candy from a baby \uD83D\uDC76",
+ "text": "Your scaring will probably make a baby cry... but that's the limit on your frightening powers. Be careful not to get to the point where everyone's running away from you because they don't like you, not because they're scared of you.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/baby.jpeg"
+ },
+ "20": {
+ "title": "\uD83C\uDFDA You're skills are forming... \uD83C\uDFDA",
+ "text": "As you become the Devil's apprentice, you begin to make people jump every time you sneak up on them. A good start, but you have to learn not to wear the same costume every year until it doesn't fit you. People will notice you and your prowess will decrease.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/tiger.jpeg"
+ },
+ "30": {
+ "title": "\uD83D\uDC80 Picture Perfect... \uD83D\uDC80",
+ "text": "You've nailed the costume this year! You look suuuper scary! Now make sure to play the part and act out your costume and you'll be sure to give a few people a massive fright!",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/costume.jpeg"
+ },
+ "50": {
+ "title": "\uD83D\uDC7B Uhm... are you human \uD83D\uDC7B",
+ "text": "Uhm... you're too good to be human and now you're beginning to sound like a ghost. You're almost invisible when haunting and nobody truly knows where you are at any given time. But they will always scream at the sound of a ghost...",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/ghost.jpeg"
+ },
+ "65": {
+ "title": "\uD83C\uDF83 That potion can't be real \uD83C\uDF83",
+ "text": "You're carrying... some... unknown liquids and no one knows who they are but yourself. Be careful on who you use these powerful spells on, because no Mage has the power to do any irreversible enchantments because even you won't know what will happen to these mortals.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/necromancer.jepg"
+ },
+ "80": {
+ "title": "\uD83E\uDD21 The most sinister face \uD83E\uDD21",
+ "text": "Who knew something intended to be playful could be so menacing... Especially other people seeing you in their nightmares, continuing to haunt them day by day, stuck in their head throughout the entire year. Make sure to pull a face they will never forget.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/clown.jpeg"
+ },
+ "95": {
+ "title": "\uD83D\uDE08 The Devil's Accomplice \uD83D\uDE08",
+ "text": "Imagine being allies with the most evil character with an aim to scare people to death. Force people to suffer as they proceed straight to hell to meet your boss and best friend. Not even you know the power He has...",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/jackolantern.jpg"
+ },
+ "100": {
+ "title":"\uD83D\uDC7F The Devil Himself \uD83D\uDC7F",
+ "text": "You are the evillest creature in existence to scare anyone and everyone humanly possible. The reason your underlings are called mortals is that they die. With your help, they die a lot quicker. With all the evil power in the universe, you know what to do.",
+ "image": "https://raw.githubusercontent.com/python-discord/seasonalbot/master/bot/resources/halloween/spookyrating/devil.jpeg"
+ }
+} \ No newline at end of file
diff --git a/bot/resources/halloween/spookyrating/baby.jpeg b/bot/resources/halloween/spookyrating/baby.jpeg
new file mode 100644
index 00000000..199f8bca
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/baby.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/candle.jpeg b/bot/resources/halloween/spookyrating/candle.jpeg
new file mode 100644
index 00000000..9913752b
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/candle.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/clown.jpeg b/bot/resources/halloween/spookyrating/clown.jpeg
new file mode 100644
index 00000000..f23c4f70
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/clown.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/costume.jpeg b/bot/resources/halloween/spookyrating/costume.jpeg
new file mode 100644
index 00000000..b3c21af0
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/costume.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/devil.jpeg b/bot/resources/halloween/spookyrating/devil.jpeg
new file mode 100644
index 00000000..4f45aaa7
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/devil.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/ghost.jpeg b/bot/resources/halloween/spookyrating/ghost.jpeg
new file mode 100644
index 00000000..0cb13346
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/ghost.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/jackolantern.jpeg b/bot/resources/halloween/spookyrating/jackolantern.jpeg
new file mode 100644
index 00000000..d7cf3d08
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/jackolantern.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/necromancer.jpeg b/bot/resources/halloween/spookyrating/necromancer.jpeg
new file mode 100644
index 00000000..60b1e689
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/necromancer.jpeg
Binary files differ
diff --git a/bot/resources/halloween/spookyrating/tiger.jpeg b/bot/resources/halloween/spookyrating/tiger.jpeg
new file mode 100644
index 00000000..0419f5df
--- /dev/null
+++ b/bot/resources/halloween/spookyrating/tiger.jpeg
Binary files differ
diff --git a/bot/seasons/halloween/spookyrating.py b/bot/seasons/halloween/spookyrating.py
new file mode 100644
index 00000000..a9cfda9b
--- /dev/null
+++ b/bot/seasons/halloween/spookyrating.py
@@ -0,0 +1,68 @@
+import bisect
+import json
+import logging
+import random
+from pathlib import Path
+
+import discord
+from discord.ext import commands
+
+from bot.constants import Colours
+
+log = logging.getLogger(__name__)
+
+with Path('bot', 'resources', 'halloween', 'spooky_rating.json').open() as file:
+ SPOOKY_DATA = json.load(file)
+ SPOOKY_DATA = sorted((int(key), value) for key, value in SPOOKY_DATA.items())
+
+
+class SpookyRating(commands.Cog):
+ """A cog for calculating one's spooky rating"""
+
+ def __init__(self, bot):
+ self.bot = bot
+ self.local_random = random.Random()
+
+ @commands.command()
+ @commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
+ async def spookyrating(self, ctx, who: discord.Member = None):
+ """
+ Calculates the spooky rating of someone.
+
+ Any user will always yield the same result, no matter who calls the command
+ """
+
+ if who is None:
+ who = ctx.author
+
+ # This ensures that the same result over multiple runtimes
+ self.local_random.seed(who.id)
+ spooky_percent = self.local_random.randint(1, 101)
+
+ # We need the -1 due to how bisect returns the point
+ # see the documentation for further detail
+ # https://docs.python.org/3/library/bisect.html#bisect.bisect
+ index = bisect.bisect(SPOOKY_DATA, (spooky_percent,)) - 1
+
+ _, data = SPOOKY_DATA[index]
+
+ embed = discord.Embed(
+ title=data['title'],
+ description=f'{who} scored {spooky_percent}%!',
+ color=Colours.orange
+ )
+ embed.add_field(
+ name='A whisper from Satan',
+ value=data['text']
+ )
+ embed.set_thumbnail(
+ url=data['image']
+ )
+
+ await ctx.send(embed=embed)
+
+
+def setup(bot):
+ """Cog load."""
+ bot.add_cog(SpookyRating(bot))
+ log.info("SpookyRating cog loaded")