Exemple #1
0
    async def filter(self, ctx, *, commands : str = ''):
        commands = commands.split('!filter')
        for k,v in enumerate(commands):
            commands[k] = shlex.split(v)
        
        # Help command
        if(commands[0][0] == 'help'):
            await ctx.send("Filters: https://ffmpeg.org/ffmpeg-filters.html\nUtilities: https://ffmpeg.org/ffmpeg-utils.html")
            return

        # Remove invalid commands
        commands_copy = commands
        commands = []
        invalid_commands_msg = ''
        for command in commands_copy:
            if(command[0] not in self.a_filters and command[0] not in self.v_filters):
                invalid_commands_msg += f'{command[0]} is not supported... yet?\n'
            else:
                commands.append(command)
        if(invalid_commands_msg != ''):
            if(len(commands) == 0):
                await ctx.send('None of those filters are supported... yet?')
                return
            else:
                await ctx.send(f'{invalid_commands_msg}Remaining filters will still be applied.')

        await video_creator.apply_filters_and_send(ctx, self._filter, {'commands':commands})
Exemple #2
0
 async def disable(self, ctx, *, command):
     if not command in ["help"]:
         command = self.bot.get_command(command)
         if command is None:
             em = discord.Embed(
                 description=f"This command hasn't been found",
                 color=color())
             await ctx.reply(embed=em, mention_author=False)
         elif command.hidden:
             em = discord.Embed(
                 description=f"This command hasn't been found",
                 color=color())
             await ctx.reply(embed=em, mention_author=False)
         else:
             command_name = "".join(
                 command.name if command.parent is None else
                 f"{command.parent.name} {command.name}")
             try:
                 await self.bot.db.execute(
                     "INSERT INTO commands (guild, commands) VALUES ($1, $2)",
                     ctx.guild.id, command_name)
             except asyncpg.UniqueViolationError:
                 commands = await self.bot.db.fetchrow(
                     "SELECT commands FROM commands WHERE guild = $1",
                     ctx.guild.id)
                 commands = commands["commands"]
                 commands = commands.split(",")
                 if not command_name in commands:
                     commands.append(command_name)
                     commands = ",".join(cmd for cmd in commands)
                     await self.bot.db.execute(
                         "UPDATE commands SET commands = $1 WHERE guild = $2",
                         commands, ctx.guild.id)
                     em = discord.Embed(
                         description=
                         f"I've successfully disabled the `{command_name}` command",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
                 else:
                     em = discord.Embed(
                         description=f"That command is already disabled",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
             else:
                 em = discord.Embed(
                     description=
                     f"I've successfully disabled the `{command_name}` command",
                     color=color())
                 await ctx.reply(embed=em, mention_author=False)
     else:
         em = discord.Embed(
             description=
             f"You are not allowed to disable the `{command}` command",
             color=color())
         await ctx.reply(embed=em, mention_author=False)
Exemple #3
0
 async def enable(self, ctx, *, command):
     command = self.bot.get_command(command)
     if command is None:
         em = discord.Embed(description=f"This command hasn't been found",
                            color=color())
         await ctx.reply(embed=em, mention_author=False)
     elif command.hidden:
         em = discord.Embed(description=f"This command hasn't been found",
                            color=color())
         await ctx.reply(embed=em, mention_author=False)
     else:
         res = await self.bot.db.fetchrow(
             "SELECT commands FROM commands WHERE guild = $1", ctx.guild.id)
         try:
             res["commands"]
         except TypeError:
             em = discord.Embed(description=f"That command isn't disabled",
                                color=color())
             await ctx.reply(embed=em, mention_author=False)
         else:
             commands = await self.bot.db.fetchrow(
                 "SELECT commands FROM commands WHERE guild = $1",
                 ctx.guild.id)
             commands = commands["commands"]
             commands = commands.split(",")
             command_name = "".join(
                 command.name if command.parent is None else
                 f"{command.parent.name} {command.name}")
             if command_name in commands:
                 commands.remove(command_name)
                 commands = ",".join(cmd for cmd in commands)
                 if len(commands) != 1:
                     await self.bot.db.execute(
                         "UPDATE commands SET commands = $1 WHERE guild = $2",
                         commands, ctx.guild.id)
                     em = discord.Embed(
                         description=
                         f"I've successfully enabled the `{command_name}` command",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
                 else:
                     await self.bot.db.fetch(
                         "DELETE FROM commands WHERE guild = $1",
                         ctx.guild.id)
                     em = discord.Embed(
                         description=
                         f"I've successfully enabled the `{command_name}` command",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
             else:
                 em = discord.Embed(
                     description=f"That command isn't disabled",
                     color=color())
                 await ctx.reply(embed=em, mention_author=False)
Exemple #4
0
    async def multichg(self, ctx, *, commands):
        new_statuses = [[j.strip() for j in i.strip().split(' ')]
                        for i in commands.split('\n')]
        for status in new_statuses:
            suggestion = await self.change_suggestion_status_back(
                ctx, int(status[0]), status[1],
                ' '.join(status[2:]) if len(status) > 2 else None)
            if status[1] == 'Mod-vote':
                m = await self.bot.get_channel(cfg.Config.config['suggestion_channel']). \
                    fetch_message(suggestion.msgid)
                await self.bot.get_channel(cfg.Config.config['mod_vote_chan']
                                           ).send(m.content)

            await ctx.send(f'Done {status}')
Exemple #5
0
 async def wink(self, ctx: commands.Context, *, commands: str = None):
     """
     Wink (smart home) commands
     """
     if commands:
         commands = commands.split()
         control = False
         device = None
         device_type = None
         if commands[-1].isnumeric(
         ):  # ended with number, so controlling brightness on bulb
             name = ' '.join(commands[0:-1])
             device, device_type = self.findDeviceOrGroup(name)
             control = True
         else:
             name = ' '.join(commands)
             device, device_type = self.findDeviceOrGroup(name)
         if device:
             if device_type == 'light_bulb':
                 if control:
                     device.set_state(device.state(),
                                      brightness=float(commands[-1]) / 100)
                 else:
                     device.set_state(not device.state())
             device.update_state()
         else:
             command = ' '.join(commands)
             if command in ['list', 'device', 'devices']:
                 r = self.listDevices()
                 if r:
                     await ctx.send(r)
             elif command in ['lights', 'bulbs']:
                 r = self.listLights()
                 if r:
                     await ctx.send(r)
             elif command in ['group', 'groups']:
                 r = self.listGroups()
                 if r:
                     await ctx.send(r)
             elif 'nick' in command:
                 if self.setNickname(command):
                     await ctx.send("Nickname saved.")
                 else:
                     await ctx.send("Nickname could not be saved.")
             else:
                 await ctx.send("I couldn't find that device.")
     else:
         await ctx.send("What command?")
Exemple #6
0
    async def guild_disable(self, ctx, *, commands: str = None):

        cmds = commands.split(" ")
        to_disable = []
        channels = self.db.query(Channel).filter_by(
            guild_id=ctx.guild.id).all()

        valid_cmds = [c.name for c in self.bot.commands]
        if cmds[0] == 'all':
            cmds = valid_cmds

        for c in cmds:
            if (c not in self.bot.auto_enable) and (c in valid_cmds):
                to_disable.append(c)

        if to_disable:
            self._disable(ctx, to_disable, channels=channels)
            await ctx.channel.send("Disabled: ```{0}```".format(
                '\n'.join(to_disable)))
        else:
            await ctx.channel.send("Failed.")
Exemple #7
0
 async def on_message_delete(self, msg):
     if not msg.author.bot and msg.guild is not None:
         res = await self.bot.db.fetchrow(
             "SELECT commands FROM commands WHERE guild = $1", msg.guild.id)
         try:
             commands = res["commands"]
         except TypeError:
             commands = ""
         commands = commands.split(",")
         if "snipe" in commands:
             return
         self.bot.message_cache[msg.guild.id] = {}
         self.bot.message_cache[msg.guild.id][msg.channel.id] = msg
         await asyncio.sleep(10)
         try:
             message = self.bot.message_cache[msg.guild.id][msg.channel.id]
         except Exception:
             pass
         else:
             if message == msg:
                 self.bot.message_cache[msg.guild.id].pop(msg.channel.id)
Exemple #8
0
    async def enable(self, ctx, *, commands: str = None):

        if not commands:
            await ctx.channel.send("Please specify commands to enable.")
            return

        cmds = commands.split(" ")
        to_enable = []

        valid_cmds = [c.name for c in self.bot.commands]
        if cmds[0] == 'all':
            cmds = valid_cmds

        for c in cmds:
            if (c not in self.bot.auto_enable) and (c in valid_cmds):
                to_enable.append(c)

        if to_enable:
            self._enable(ctx, to_enable)
            await ctx.channel.send("Enabled: ```{0}```".format(
                '\n'.join(to_enable)))
        else:
            await ctx.channel.send("Failed.")
Exemple #9
0
    async def on_message(self, msg):
        if self.emptyPrefix:
            await self.process_commands(msg)
            return

        if pwd.getpwuid(os.getuid())[0] != "pi":
            if not is_mod(self, msg.author):
                return
        
        prefix = await get_prefix(self, msg)
        
        if msg.guild is None:
            if msg.content.startswith(prefix):
                return await msg.channel.send(f"DM commands are disabled, please invite me to a guild\nInvite: https://discord.com/api/oauth2/authorize?client_id={self.user.id}&permissions=8&scope=self\nSupport Server: {self.invite}")

        if msg.author.bot:
            return

        if await is_blacklisted(self, msg.author):
            return

        for i in prefix:
            if msg.content.startswith(i):
                    
                if msg.guild is not None:
                    try:
                        command = msg.content.split(i)
                    except ValueError:
                        command = msg.content
                    command = command[1]
                    res = await self.db.fetchrow("SELECT commands FROM commands WHERE guild = $1", msg.guild.id)
                    try:
                        commands = res["commands"]
                    except:
                        success = False
                    else:
                        success = True
                    if success:
                        command_obj = self.get_command(command)
                        try:
                            self.get_command(command).parent
                        except:
                            command_name = None
                        else:
                            command_name = "".join(command_obj.name if command_obj.parent is None else f"{command_obj.parent.name} {command_obj.name}")
                        commands = commands.split(",")
                        if command_name in commands and command != "":
                            if is_mod(self, msg.author):
                                pass
                            else:
                                em=discord.Embed(description=f"This command has been disabled by the server administrators", color=color())
                                return await msg.channel.send(embed=em)
                        else:
                            pass
                    else:
                        pass
                await self.process_commands(msg)
                return
            
            if msg.content == f"<@!{self.user.id}>" or msg.content == f"<@{self.user.id}>":
                if msg.guild:
                    em=discord.Embed(description=f"The prefix for `{msg.guild.name}` is `{prefix[2]}`", color=color())
                    return await msg.channel.send(embed=em)
                else:
                    em=discord.Embed(description=f"The prefix for dms is `{prefix[2]}`", color=color())
                    return await msg.channel.send(embed=em)
Exemple #10
0
    async def disable(self,
                      ctx: commands.Context,
                      *,
                      commands: str = None) -> None:
        """
        disable_help
        examples:
        -disable ping
        -disable ping help about
        """
        _disabled = self.db.configs.get(ctx.guild.id, "disabled_commands")

        if commands == None:
            if len(_disabled) < 1:
                return await ctx.send(
                    self.locale.t(ctx.guild,
                                  "no_disabled_commands",
                                  _emote="NO"))
            else:
                e = Embed(title="Disabled commands (mod-only)",
                          description=", ".join(
                              [f"``{x}``" for x in _disabled]))
                return await ctx.send(embed=e)

        commands = commands.split(" ")
        enabled = []
        disabled = []
        failed = []
        for cmd in commands:
            cmd = cmd.lower()
            if cmd in self.bot.all_commands:
                if not cmd in _disabled:
                    if len((self.bot.get_command(cmd)).checks) < 1:
                        _disabled.append(cmd)
                        disabled.append(cmd)
                    else:
                        failed.append(cmd)
                else:
                    enabled.append(cmd)
                    _disabled.remove(cmd)
            else:
                failed.append(cmd)

        if (len(enabled) + len(disabled)) < 1:
            return await ctx.send(
                self.locale.t(ctx.guild, "no_changes", _emote="NO"))

        self.db.configs.update(ctx.guild.id, "disabled_commands", disabled)
        e = Embed(title="Command config changes")
        if len(disabled) > 0:
            e.add_field(name="❯ Disabled the following commands",
                        value=", ".join([f"``{x}``" for x in disabled]))
        if len(enabled) > 0:
            e.add_field(
                name="❯ Re-enabled the following commands",
                value=", ".join([f"``{x}``" for x in enabled]),
            )
        if len(failed) > 0:
            e.add_field(
                name="❯ Following commands are unknown or mod-commands",
                value=", ".join([f"``{x}``" for x in failed]),
            )

        await ctx.send(embed=e)
Exemple #11
0
 async def combo(self, ctx, *, commands: str):
     for command in commands.split(" && "):
         await ctx.invoke(self.bot.get_command(command))
     await ctx.message.add_reaction(":Ok:501773759011749898")
Exemple #12
0
 async def exec(self, ctx, *, commands):
     all_commands = commands.split(';;')
     for content in all_commands:
         command = bot.SubcommandMessage(message=ctx.message)
         command.content = content.strip()
         await self.bot.process_commands(command)