Add ctc2 commands, closes #4
This commit is contained in:
parent
244d98979f
commit
65b671faa2
4 changed files with 133 additions and 70 deletions
|
@ -19,7 +19,7 @@ restart_ctx = None
|
||||||
jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents)
|
jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents)
|
||||||
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
|
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
|
||||||
jarvis_self = Process()
|
jarvis_self = Process()
|
||||||
__version__ = "0.4.0"
|
__version__ = "0.4.1"
|
||||||
|
|
||||||
|
|
||||||
@jarvis.event
|
@jarvis.event
|
||||||
|
|
58
jarvis/cogs/ctc2.py
Normal file
58
jarvis/cogs/ctc2.py
Normal file
|
@ -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))
|
|
@ -1,13 +1,12 @@
|
||||||
import jarvis
|
import jarvis
|
||||||
import re
|
import re
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import html
|
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.field import Field
|
from jarvis.utils.field import Field
|
||||||
from jarvis.data.dbrand import shipping_lookup
|
from jarvis.data.dbrand import shipping_lookup
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord_slash import cog_ext, SlashContext
|
from discord_slash import cog_ext
|
||||||
|
|
||||||
|
|
||||||
class DbrandCog(commands.Cog):
|
class DbrandCog(commands.Cog):
|
||||||
|
|
28
schema.yaml
28
schema.yaml
|
@ -1,10 +1,11 @@
|
||||||
# J.A.R.V.I.S. database layout
|
# J.A.R.V.I.S. database layout
|
||||||
|
|
||||||
config:
|
jarvis:
|
||||||
|
config:
|
||||||
key: String, config name
|
key: String, config name
|
||||||
value: Any, config value
|
value: Any, config value
|
||||||
|
|
||||||
bans:
|
bans:
|
||||||
user: User ID
|
user: User ID
|
||||||
reason: String, default "Mr. Stark is displeased with your presence. Please leave."
|
reason: String, default "Mr. Stark is displeased with your presence. Please leave."
|
||||||
admin: User ID, admin who banned user
|
admin: User ID, admin who banned user
|
||||||
|
@ -14,14 +15,14 @@ bans:
|
||||||
length: Optional(int), required for type=="temp", ban length in days, default 1
|
length: Optional(int), required for type=="temp", ban length in days, default 1
|
||||||
active: boolean, if ban is active
|
active: boolean, if ban is active
|
||||||
|
|
||||||
kicks:
|
kicks:
|
||||||
user: User ID
|
user: User ID
|
||||||
reason: String, default "Mr. Stark is displeased with your presence. Please leave."
|
reason: String, default "Mr. Stark is displeased with your presence. Please leave."
|
||||||
admin: User ID, admin who kicked user
|
admin: User ID, admin who kicked user
|
||||||
time: Datetime
|
time: Datetime
|
||||||
guild: Guild ID
|
guild: Guild ID
|
||||||
|
|
||||||
mutes:
|
mutes:
|
||||||
user: User ID
|
user: User ID
|
||||||
reason: String, default "Mr. Stark is annoyed by your voice. Please be quiet."
|
reason: String, default "Mr. Stark is annoyed by your voice. Please be quiet."
|
||||||
admin: User ID, admin who muted user
|
admin: User ID, admin who muted user
|
||||||
|
@ -31,7 +32,7 @@ mutes:
|
||||||
length: int, mute length in minutes, default 30, -1 for permanent
|
length: int, mute length in minutes, default 30, -1 for permanent
|
||||||
active: boolean, if mute is active
|
active: boolean, if mute is active
|
||||||
|
|
||||||
warns:
|
warns:
|
||||||
user: User ID
|
user: User ID
|
||||||
reason: String, default "Mr. Stark has defined rules of conduct. Please read them."
|
reason: String, default "Mr. Stark has defined rules of conduct. Please read them."
|
||||||
admin: User ID, admin who warned user
|
admin: User ID, admin who warned user
|
||||||
|
@ -40,7 +41,7 @@ warns:
|
||||||
expiry: int, hours from warning until it expires, default 24
|
expiry: int, hours from warning until it expires, default 24
|
||||||
active: boolean, if warning is active or expired
|
active: boolean, if warning is active or expired
|
||||||
|
|
||||||
jokes:
|
jokes:
|
||||||
id: String, Reddit post ID
|
id: String, Reddit post ID
|
||||||
body: String, joke text
|
body: String, joke text
|
||||||
created_utc: int, epoch timestamp of upload
|
created_utc: int, epoch timestamp of upload
|
||||||
|
@ -48,32 +49,37 @@ jokes:
|
||||||
score: int, Reddit upvote score
|
score: int, Reddit upvote score
|
||||||
title: string, joke title
|
title: string, joke title
|
||||||
|
|
||||||
locks:
|
locks:
|
||||||
channel: Channel ID
|
channel: Channel ID
|
||||||
reason: String, default "Mr. Stark is reviewing this channel. Please hold on."
|
reason: String, default "Mr. Stark is reviewing this channel. Please hold on."
|
||||||
admin: User ID, admin who locked channel
|
admin: User ID, admin who locked channel
|
||||||
guild: Guild ID
|
guild: Guild ID
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
guild: Guild ID
|
guild: Guild ID
|
||||||
setting: String, setting name
|
setting: String, setting name
|
||||||
value: Any, setting value
|
value: Any, setting value
|
||||||
|
|
||||||
autoreact:
|
autoreact:
|
||||||
guild: Guild ID
|
guild: Guild ID
|
||||||
channel: Channel ID
|
channel: Channel ID
|
||||||
reactions: List[Emote ID]
|
reactions: List[Emote ID]
|
||||||
admin: User ID, admin who added autoreact
|
admin: User ID, admin who added autoreact
|
||||||
time: datetime
|
time: datetime
|
||||||
|
|
||||||
stars:
|
stars:
|
||||||
message: Message ID
|
message: Message ID
|
||||||
channel: Channel ID
|
channel: Channel ID
|
||||||
guild: Guild ID
|
guild: Guild ID
|
||||||
admin: User ID, admin who starred
|
admin: User ID, admin who starred
|
||||||
time: Datetime
|
time: Datetime
|
||||||
|
|
||||||
modlog:
|
modlog:
|
||||||
user: User ID
|
user: User ID
|
||||||
activity: String
|
activity: String
|
||||||
time: Datetime
|
time: Datetime
|
||||||
|
ctc2:
|
||||||
|
guesses:
|
||||||
|
guess: String
|
||||||
|
user: User ID
|
||||||
|
correct: boolean
|
||||||
|
|
Loading…
Add table
Reference in a new issue