Ejemplo n.º 1
0
    async def exec_cmd(self, **kwargs):
        session = kwargs['session']
        settings = server_settings(session, self.server)
        if self.author.id not in settings.admins_ids:
            self.client.send_message(self.channel, 'nope, sorry')
            return
        if 'defaultrole' in self.content.lower():
            settings.default_role_id = self.message.role_mentions[0].id
        elif 'botcommands' in self.content.lower():
            bc_channels = settings.bot_commands_channels
            new_channels = self.message.channel_mentions or [self.channel.id]

            for channel in new_channels:
                if channel.id in bc_channels:
                    bc_channels.remove(channel.id)
                else:
                    bc_channels.append(channel.id)
                print(bc_channels)
                settings.bot_commands_channels = bc_channels

        elif 'aut-emoji' in self.content.lower():
            settings.aut_emoji = self.args[2]
        elif 'nice-emoji' in self.content.lower():
            settings.nice_emoji = self.args[2]
        elif 'toxic-emoji' in self.content.lower():
            settings.toxic_emoji = self.args[2]
        elif 'bot-emoji' in self.content.lower():
            settings.bot_emoji = self.args[2]
        elif 'norm-emoji' in self.content.lower():
            settings.norm_emoji = self.args[2]
        elif 'edit-emoji' in self.content.lower():
            settings.edit_emoji = self.args[2]

        elif 'admin' in self.content.lower():
            if self.message.mentions[0].id in settings.admins_ids:
                settings.admins_ids.remove(self.message.mentions[0].id)
            else:
                settings.admins_ids += [self.message.mentions[0].id]

        await self.client.send_message(self.channel,
                                       str(settings._settings_dict))
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
async def on_message(message):
    if message.channel.is_private and message.author != client.user:
        await client.send_message(await client.get_user_info(JOHNYS_ID), message.author.mention + ': '+message.content)
        return
    server = message.channel.server
    cache[server]['messages'][message.channel] = None
    print(log_message(message))
    settings = server_settings(session, server)
    if 'gfycat.com' in message.content or 'clips.twitch' in message.content and not message.author.bot:
        if message.channel == server.default_channel:
            parser = re.compile('(clips\.twitch\.tv\/|gfycat\.com\/)([^ ]+)', re.IGNORECASE)
            match = parser.search(message.content)
            if match:
                highlights = discord.utils.get(server.channels, name='highlights', type=ChannelType.text)
                url = 'https://' + match.group(1) + match.group(2)
                await client.send_message(highlights, url)

    args = message.clean_content.split(' ')
    if args and args[0][0] in BOT_PREFIX:
        for name, command in default_cmds.items():
            if args[0][1:] in command.get_aliases():
                print (command.name)
                print (command.format_help(args[0], settings=settings))

    
    if not message.author.bot:
        await client.process_commands(message)
        for command in smart_commands[int(message.channel.server.id)]:
            if (command.triggered(message.content)):
                resp = command.generate_response(message.author, message.content)
                update_command(command.raw_trigger, command.raw_response, command.count, command.server, command.author_id)
                reacts = command.generate_reacts()
                if resp:
                    await client.send_message(message.channel, resp)
                for react in reacts:
                    await client.add_reaction(message, react)
                break
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def initialize_admins():
    for server in client.servers:
        settings = server_settings(session, server)
        admins[int(server.id)] = [int(admin) for admin in settings.admins_ids]
Ejemplo n.º 6
0
def initialize_settings():
    for guild in client.guilds:
        settings_dict[guild] = server_settings(session, guild)