diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 144a116..021aaf7 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -19,7 +19,7 @@ restart_ctx = None jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) jarvis_self = Process() -__version__ = "0.4.0" +__version__ = "0.4.1" @jarvis.event diff --git a/jarvis/cogs/ctc2.py b/jarvis/cogs/ctc2.py new file mode 100644 index 0000000..be1f878 --- /dev/null +++ b/jarvis/cogs/ctc2.py @@ -0,0 +1,58 @@ +import jarvis +import re +import aiohttp +from jarvis.config import get_config +from jarvis.utils import build_embed +from jarvis.utils.db import DBManager +from jarvis.utils.field import Field +from jarvis.data.dbrand import shipping_lookup +from discord.ext import commands +from discord_slash import cog_ext + + +class CTCCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + mconf = get_config().mongo + self.db = DBManager(mconf).mongo + self._session = aiohttp.ClientSession() + self.url = "https://completethecodetwo.cards/pw" + + @cog_ext.cog_subcommand( + base="ctc2", + name="about", + description="CTC2 related commands", + guild_ids=[578757004059738142], + ) + async def _about(self, ctx): + await ctx.send( + "See https://phase2.completethecode.com for more information" + ) + + @cog_ext.cog_subcommand( + base="ctc2", + name="pw", + description="Guess a password for https://completethecodetwo.cards", + guild_ids=[578757004059738142], + ) + async def _pw(self, ctx, guess: str): + guessed = self.db.ctc2.guesses.find_one({"guess": guess}) + if guessed: + await ctx.send("Already guessed, dipshit.") + return + result = await self._session.post(self.url, data=guess) + message = "" + correct = False + if 200 <= result.status < 400: + message = f"{ctx.author.mention} got it! Password is {guess}!" + correct = True + else: + message = "Nope." + self.db.ctc2.guesses.insert_one( + {"guess": guess, "user": ctx.author.id, "correct": correct} + ) + await ctx.send(message) + + +def setup(bot): + bot.add_cog(CTCCog(bot)) diff --git a/jarvis/cogs/dbrand.py b/jarvis/cogs/dbrand.py index 6232480..7c516e2 100644 --- a/jarvis/cogs/dbrand.py +++ b/jarvis/cogs/dbrand.py @@ -1,13 +1,12 @@ import jarvis import re import aiohttp -import html from jarvis.config import get_config from jarvis.utils import build_embed from jarvis.utils.field import Field from jarvis.data.dbrand import shipping_lookup from discord.ext import commands -from discord_slash import cog_ext, SlashContext +from discord_slash import cog_ext class DbrandCog(commands.Cog): diff --git a/schema.yaml b/schema.yaml index c32f559..9e14d2d 100644 --- a/schema.yaml +++ b/schema.yaml @@ -1,79 +1,85 @@ # J.A.R.V.I.S. database layout -config: - key: String, config name - value: Any, config value +jarvis: + config: + key: String, config name + value: Any, config value -bans: - user: User ID - reason: String, default "Mr. Stark is displeased with your presence. Please leave." - admin: User ID, admin who banned user - time: Datetime - guild: Guild ID - type: String ("temp" | "soft" | "perm"), ban type, default "perm" - length: Optional(int), required for type=="temp", ban length in days, default 1 - active: boolean, if ban is active + bans: + user: User ID + reason: String, default "Mr. Stark is displeased with your presence. Please leave." + admin: User ID, admin who banned user + time: Datetime + guild: Guild ID + type: String ("temp" | "soft" | "perm"), ban type, default "perm" + length: Optional(int), required for type=="temp", ban length in days, default 1 + active: boolean, if ban is active -kicks: - user: User ID - reason: String, default "Mr. Stark is displeased with your presence. Please leave." - admin: User ID, admin who kicked user - time: Datetime - guild: Guild ID + kicks: + user: User ID + reason: String, default "Mr. Stark is displeased with your presence. Please leave." + admin: User ID, admin who kicked user + time: Datetime + guild: Guild ID -mutes: - user: User ID - reason: String, default "Mr. Stark is annoyed by your voice. Please be quiet." - admin: User ID, admin who muted user - time: datetime - guild: Guild ID - type: String ("voice" | "text" | "all"), mute type, default "all" - length: int, mute length in minutes, default 30, -1 for permanent - active: boolean, if mute is active + mutes: + user: User ID + reason: String, default "Mr. Stark is annoyed by your voice. Please be quiet." + admin: User ID, admin who muted user + time: datetime + guild: Guild ID + type: String ("voice" | "text" | "all"), mute type, default "all" + length: int, mute length in minutes, default 30, -1 for permanent + active: boolean, if mute is active -warns: - user: User ID - reason: String, default "Mr. Stark has defined rules of conduct. Please read them." - admin: User ID, admin who warned user - time: datetime - guild: Guild ID - expiry: int, hours from warning until it expires, default 24 - active: boolean, if warning is active or expired + warns: + user: User ID + reason: String, default "Mr. Stark has defined rules of conduct. Please read them." + admin: User ID, admin who warned user + time: datetime + guild: Guild ID + expiry: int, hours from warning until it expires, default 24 + active: boolean, if warning is active or expired -jokes: - id: String, Reddit post ID - body: String, joke text - created_utc: int, epoch timestamp of upload - over_18: boolean, NSFW - score: int, Reddit upvote score - title: string, joke title + jokes: + id: String, Reddit post ID + body: String, joke text + created_utc: int, epoch timestamp of upload + over_18: boolean, NSFW + score: int, Reddit upvote score + title: string, joke title -locks: - channel: Channel ID - reason: String, default "Mr. Stark is reviewing this channel. Please hold on." - admin: User ID, admin who locked channel - guild: Guild ID + locks: + channel: Channel ID + reason: String, default "Mr. Stark is reviewing this channel. Please hold on." + admin: User ID, admin who locked channel + guild: Guild ID -settings: - guild: Guild ID - setting: String, setting name - value: Any, setting value + settings: + guild: Guild ID + setting: String, setting name + value: Any, setting value -autoreact: - guild: Guild ID - channel: Channel ID - reactions: List[Emote ID] - admin: User ID, admin who added autoreact - time: datetime + autoreact: + guild: Guild ID + channel: Channel ID + reactions: List[Emote ID] + admin: User ID, admin who added autoreact + time: datetime -stars: - message: Message ID - channel: Channel ID - guild: Guild ID - admin: User ID, admin who starred - time: Datetime + stars: + message: Message ID + channel: Channel ID + guild: Guild ID + admin: User ID, admin who starred + time: Datetime -modlog: - user: User ID - activity: String - time: Datetime + modlog: + user: User ID + activity: String + time: Datetime +ctc2: + guesses: + guess: String + user: User ID + correct: boolean