Ejemplo n.º 1
0
def handle_discord_request(ctx, command, args):
    request = " ".join(args)
    user_disc = ctx.author.name + ctx.author.discriminator
    username = db.get_name_from_discriminator(user_disc)

    try:
        request_dict = dissect_comment(f"!{command} {request}")
    except (MovieNotFound, EpisodeNotFound, OffensiveWord,
            InvalidRequest) as kino_exc:
        return f"Nope: {type(kino_exc).__name__}."

    request_id = str(randint(2000000, 5000000))

    if not request_dict:
        return "Invalid syntax."
    elif not username:
        return "You are not registered. Use `!register <YOUR NAME>`."

    try:
        db.insert_request((
            username[0],
            request_dict["comment"],
            request_dict["command"],
            request_dict["title"],
            "|".join(request_dict["content"]),
            request_id,
            1,
        ))
        db.verify_request(request_id)
        return f"Added. ID: {request_id}; user: {username[0]}."
    except sqlite3.IntegrityError:
        return "Duplicate request."
Ejemplo n.º 2
0
async def on_reaction_add(reaction, user):
    if user.bot:
        return

    if not str(reaction) in GOOD_BAD + EMOJI_STRS:
        return

    if not str(user.top_role) in "botmin verifier":
        return

    channel = bot.get_channel(reaction.message.channel.id)
    content = reaction.message.content

    if content.startswith("1. "):
        split_ = content.split("\n")
        try:
            index = split_[RANGE_DICT[str(reaction)]]
        except IndexError:
            return await channel.send("apoco si pa")

        request_id = index.split("-")[-1].strip()
        return await channel.send(db.verify_request(request_id))

    item_id = get_id_from_discord(content)

    if content.startswith("Added") and str(reaction) == GOOD_BAD[1]:
        return await channel.send(db.remove_request(item_id))

    if content.startswith("Possible NSFW") and str(reaction) == GOOD_BAD[0]:
        return await channel.send(db.verify_request(item_id))
Ejemplo n.º 3
0
async def on_reaction_add(reaction, user):
    if user.bot or not str(reaction) in GOOD_BAD or "botmin" != str(
            user.top_role):
        return

    channel = bot.get_channel(reaction.message.channel.id)
    content = reaction.message.content
    item_id = get_id_from_discord(content)

    if content.startswith("Added") and str(reaction) == GOOD_BAD[1]:
        return await channel.send(db.remove_request(item_id))

    if content.startswith("Possible NSFW") and str(reaction) == GOOD_BAD[0]:
        return await channel.send(db.verify_request(item_id))
Ejemplo n.º 4
0
async def verify(ctx, arg):
    await ctx.send(db.verify_request(arg.strip()))
Ejemplo n.º 5
0
async def verify(ctx, arg):
    db.verify_request(arg.strip())
    await ctx.send("Ok.")