Esempio n. 1
0
async def admin(context):
    server = context.message.channel.server
    if ("remove" in context.message.content
            and context.message.author.id == server.owner.id):
        for member in context.message.mentions:
            if (member == context.message.author):
                await client.send_message(context.message.channel, "🤔")
                return
            update_admin(member, server, delete=True)
            admins[int(server.id)].remove(int(member.id))
            await client.send_message(context.message.channel,
                                      "Removed %s." % member.display_name)
        return

    if ("list" in context.message.content):
        print("serverid: " + server.id)
        print(admins)
        names = ''
        for userid in admins[int(server.id)]:
            names += (server.get_member(str(userid))).display_name + ' '
        await client.send_message(context.message.channel, names)
        return
    if (context.message.author.id == server.owner.id):
        for member in context.message.mentions:
            admins.setdefault(int(server.id), [])
            if (member.id not in admins[int(server.id)]):
                new_admin = Admin(server.id, member.id, member.name)
                session.add(new_admin)
                admins[int(server.id)].append(int(member.id))
                update_admin(member, server)
                await client.send_message(context.message.channel,
                                          "Added %s." % member.display_name)
    else:
        await client.send_message(context.message.channel,
                                  "Nice try. You have been reported.")
Esempio n. 2
0
async def on_reaction_add(reaction, user):
    author = reaction.message.author
    for e in reaction.message.embeds:
        author_name, author_avatar = '', ''
        try:
            author_name = e['author']['name']
            author_avatar = e['author']['icon_url']
        except:
            pass  # not the type of embed we were expecting
        real_author = find_member(author_name, author_avatar,
                                  reaction.message.channel.server)
        if (real_author != None):
            author = real_author

    if (str(reaction.emoji) == EDIT_EMOJI
            or (reaction.custom_emoji and reaction.emoji.name == EDIT_EMOJI)):
        await add_popup(reaction.message)

    #if (str(reaction.emoji) == GULAG_EMOJI or (reaction.custom_emoji and reaction.emoji.name == GULAG_EMOJI)):
    #if reaction.count > 3
    #await add_popup(reaction.message)

    if (str(reaction.emoji) == STAR_EMOJI
            or (reaction.custom_emoji and reaction.emoji.name == STAR_EMOJI)):
        if reaction.count == 5:
            await starboard_post(reaction.message,
                                 reaction.message.channel.server)

    if ((author != user or user.id == JOHNYS_ID or user.id == MATTS_ID)
            and author != client.user and user != client.user):
        if (author.id not in karma_dict):
            karma_dict[author.id] = [2, 2, 2, 2]
            new_user = User(author.id, karma_dict[author.id])
            session.add(new_user)

        if (str(reaction.emoji) == AUT_EMOJI or
            (reaction.custom_emoji and reaction.emoji.name == AUT_EMOJI)):
            karma_dict[author.id][0] += 1
        elif (str(reaction.emoji) == NORM_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == NORM_EMOJI)):
            karma_dict[author.id][1] += 1
        elif (str(reaction.emoji) == NICE_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == NICE_EMOJI)):
            karma_dict[author.id][2] += 1
        elif (str(reaction.emoji) == TOXIC_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == TOXIC_EMOJI)):
            karma_dict[author.id][3] += 1
        update_user(author.id)
Esempio n. 3
0
async def on_reaction_add(reaction, user):
    author = reaction.message.author
    server = reaction.message.channel.server
    settings = server_settings(session, server)
    print (settings.aut_emoji)
    for e in reaction.message.embeds:
        author_name, author_avatar = '',''
        try:
            author_name = e['author']['name']
            author_avatar = e['author']['icon_url']
        except: pass # not the type of embed we were expecting
        # this won't work if the user has default avatar
        real_author = discord.utils.get(server.members, name=author_name, avatar_url=author_avatar)
        if (real_author != None):
            author = real_author

    if settings.edit_emoji in str(reaction.emoji):
        await add_popup(reaction.message)

    if STAR_EMOJI in str(reaction.emoji):
        if reaction.count == 5:
            await starboard_post(reaction.message, server)

    if ((author != user or user.id == JOHNYS_ID or user.id == MATTS_ID) and author != client.user and user != client.user):
        if (author.id not in karma_dict):
            karma_dict[author.id] = [2,2,2,2,0]
            new_user = User(author.id, karma_dict[author.id])
            session.add(new_user)

        if settings.aut_emoji in str(reaction.emoji):
            karma_dict[author.id][0] += 1
        elif settings.norm_emoji in str(reaction.emoji):
            karma_dict[author.id][1] += 1
        elif settings.nice_emoji in str(reaction.emoji):
            karma_dict[author.id][2] += 1
        elif settings.toxic_emoji in str(reaction.emoji):
            karma_dict[author.id][3] += 1
        elif settings.bot_emoji in str(reaction.emoji):
            karma_dict[author.id][4] += 1
        update_user(author.id)
Esempio n. 4
0
async def on_reaction_remove(reaction, user):
    author = reaction.message.author
    for e in reaction.message.embeds:
        try:
            author_name = e['author']['name']
            author_avatar = e['author']['icon_url']
        except:
            pass
        real_author = find_member(author_name, author_avatar,
                                  reaction.message.channel.server)
        if (real_author != None):
            author = real_author

    if (str(reaction.emoji) == EDIT_EMOJI
            or (reaction.custom_emoji and reaction.emoji.name == EDIT_EMOJI)):
        for react in reaction.message.reactions:
            if (str(reaction.emoji) == EDIT_EMOJI or
                (reaction.custom_emoji and reaction.emoji.name == EDIT_EMOJI)):
                return
        await delete_popup(reaction.message)

    if ((author != user or user.id == JOHNYS_ID) and author != client.user):
        if (author.id not in karma_dict):
            karma_dict[author.id] = [2, 2, 2, 2]
            new_user = User(author.id, karma_dict[author.id])
            session.add(new_user)
        if (str(reaction.emoji) == AUT_EMOJI or
            (reaction.custom_emoji and reaction.emoji.name == AUT_EMOJI)):
            karma_dict[author.id][0] -= 1
        elif (str(reaction.emoji) == NORM_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == NORM_EMOJI)):
            karma_dict[author.id][1] -= 1
        elif (str(reaction.emoji) == NICE_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == NICE_EMOJI)):
            karma_dict[author.id][2] -= 1
        elif (str(reaction.emoji) == TOXIC_EMOJI or
              (reaction.custom_emoji and reaction.emoji.name == TOXIC_EMOJI)):
            karma_dict[author.id][3] -= 1

        update_user(author.id)
Esempio n. 5
0
async def check(context):
    await client.send_typing(context.message.channel)
    for member in context.message.mentions:
        if (member == client.user):
            await client.send_message(
                context.message.channel,
                "Leave me out of this, " + context.message.author.mention)
            return
        if (member.id not in karma_dict):
            karma_dict[member.id] = [2, 2, 2, 2]
            new_user = User(member.id, karma_dict[member.id])
            session.add(new_user)
        response = member.display_name + " is "
        response += (
            "{:3.1f}% autistic".format(get_autism_percent(member.id)) if
            (get_autism_percent(member.id) >= get_normie_percent(member.id))
            else "{:3.1f}% normie".format(get_normie_percent(member.id)))
        response += " and " + (
            "{:3.1f}% toxic.".format(get_toxc_percent(member.id)) if
            (get_toxc_percent(member.id) >= get_nice_percent(member.id)) else
            "{:3.1f}% nice.".format(get_nice_percent(member.id)))
        await client.send_message(context.message.channel, response)
Esempio n. 6
0
async def on_reaction_remove(reaction, user):
    author = reaction.message.author
    server = reaction.message.channel.server
    settings = server_settings(session, server)
    for e in reaction.message.embeds:
        try:
            author_name = e['author']['name']
            author_avatar = e['author']['icon_url']
        except:
            pass
        real_author = discord.utils.get(server.members, name=author_name, avatar_url=author_avatar)
        if (real_author != None):
            author = real_author

    if settings.edit_emoji in str(reaction.emoji):
        for react in reaction.message.reactions:
            if settings.edit_emoji in str(react): return
        await delete_popup(reaction.message)

    if ((author != user or user.id == JOHNYS_ID) and author != client.user):
        if (author.id not in karma_dict):
            karma_dict[author.id] = [2,2,2,2,0]
            new_user = User(author.id, karma_dict[author.id])
            session.add(new_user)
        if settings.aut_emoji in str(reaction.emoji):
            karma_dict[author.id][0] -= 1
        elif settings.norm_emoji in str(reaction.emoji):
            karma_dict[author.id][1] -= 1
        elif settings.nice_emoji in str(reaction.emoji):
            karma_dict[author.id][2] -= 1
        elif settings.toxic_emoji in str(reaction.emoji):
            karma_dict[author.id][3] -= 1
        elif settings.bot_emoji in str(reaction.emoji):
            karma_dict[author.id][4] -= 1

        update_user(author.id)