Exemplo n.º 1
0
    async def on_message(self, message):

        if not self.bot.ready():
            return


        if message.author.bot: return

        if str(message.channel.type) == "private":
            return

        bot_perms = message.channel.permissions_for(message.guild.get_member(self.bot.user.id))
        if not bot_perms.send_messages:
            return

        prefix = fn.getprefix(self.bot, message)
        if not message.content.startswith(prefix):
            return
        commandcheck = message.content[len(prefix):]
        command_used = False
        for command in cm.commands:
            if commandcheck.startswith(command):
                command_used = True
                break

        if not command_used:
            return

        notice = db.getlastnotice()
        if notice:
            last_notice = db.getservernotice(message.guild.id)
            if last_notice < notice[0]:
                embed = self.create_notice(message, *notice)
                await message.channel.send(embed=embed)
                db.updateservernotice(message.guild.id)
Exemplo n.º 2
0
Arquivo: say.py Projeto: judev1/FBot
    async def send(self, ctx, filter=None, delete=False):

        reference = ctx.message.reference
        if reference:
            message = await ctx.fetch_message(id=reference.message_id)
            text = message.content
        else:
            text = ctx.message.content
            prefix = fn.getprefix(self.bot, ctx.message)
            command = ctx.command.name
            if not text.lower().startswith(prefix + command):
                for alias in ctx.command.aliases:
                    if text.lower().startswith(prefix + alias):
                        command = alias
                        break
            text = text[len(prefix) + len(command) + 1:]

        if text:
            if filter:
                text = sanitise_text(text)
                text = filter(text)

            try:
                await ctx.send(text, allowed_mentions=AllowedMentions.none())
            except:
                text = "Text is too long to send"
                if filter:
                    text = filter(text)
                await ctx.send(text)
        else:
            text = "You didn't include or reference any text to say!"
            if filter:
                text = filter(text)
            await ctx.reply(text)
Exemplo n.º 3
0
    async def respects(self, ctx):

        reference = ctx.message.reference
        if reference:
            message = await ctx.fetch_message(id=reference.message_id)
            text = message.content
        else:
            text = ctx.message.content
            prefix = len(fn.getprefix(self.bot, ctx.message))
            text = text[prefix + 9:]

        if text:
            text = capitalise(sanitise_text(text))
            message = await ctx.send(
                f"React with {F} to pay respects to **{text}**")
            await message.add_reaction(F)
            ongoing_respects[message.id] = (text, set())
        else:
            await ctx.reply(
                "You didn't include or reference anything to pay respects to!")
Exemplo n.º 4
0
Arquivo: snipe.py Projeto: judev1/FBot
    async def on_message_delete(self, message):

        if not self.bot.ready():
            return

        if not message.guild: return
        if message.author.bot: return

        bot_perms = message.channel.permissions_for(
            message.guild.get_member(self.bot.user.id))

        prefix = fn.getprefix(self.bot, message)
        commandcheck = message.content[len(prefix):]
        say_commands = tuple([
            command.name + " " for command in self.bot.commands
            if command.cog.qualified_name == "say"
        ])
        if commandcheck.startswith(say_commands):
            if not message.author.bot:
                if bot_perms.send_messages:
                    return

        deleter = "User"
        if bot_perms.view_audit_log:
            async for deleted in message.guild.audit_logs(
                    limit=1, oldest_first=False, action=message_delete):
                if deleted.target.id == message.author.id:
                    deleter = deleted.user.mention
                else:
                    deleter = message.author.mention

        if message.channel.id not in snipes:
            snipes[message.channel.id] = deque(maxlen=max_snipes)
        data = {
            "action": "deleted",
            "content": message.content,
            "sender": message.author.mention,
            "deleter": deleter,
            "time": self.bot.ftime.now()
        }
        snipes[message.channel.id].appendleft(data)
Exemplo n.º 5
0
    async def on_message(self, message):

        if not self.bot.ready():
            return

        user = message.author
        stats = self.bot.stats

        if user.bot:
            return
        if not commands.bot_has_permissions(send_messages=True):
            stats.other_messages_processed += 1
            return
        if str(message.channel.type) == "private":
            guild_id = fn.guild.id
        else:
            guild_id = message.guild.id

        prefix = fn.getprefix(self.bot, message)
        commandcheck = message.content[len(prefix):]
        for command in cm.commands:
            if commandcheck.startswith(command):
                return
        for command in cm.devcmds:
            if commandcheck.startswith(command):
                return

        priority, status = "all", "on"
        if str(message.channel.type) != "private":
            db.addchannel(message.channel.id, guild_id)
            priority = db.getpriority(guild_id)
            status = db.getstatus(message.channel.id)
        if status == "on":
            trigger_detected = tr.respond(message, priority)[0]
            if trigger_detected:
                stats.triggers_processed += 1
                db.usetrigger(user.id)
                return
        stats.other_messages_processed += 1
Exemplo n.º 6
0
    async def on_message(self, message):

        if not self.bot.ready():
            return

        if message.author.bot: return

        name = message.author.display_name
        channel = message.channel
        content = message.content

        if str(message.channel.type) != "private":
            if not message.channel.permissions_for(
                message.guild.get_member(self.bot.user.id)).send_messages:
                return

        prefix = fn.getprefix(self.bot, message)
        commandcheck = content[len(prefix):]
        for command in cm.commands:
            if commandcheck.startswith(command):
                return
        for command in cm.devcmds:
            if commandcheck.startswith(command):
                return

        if content.lower().startswith("fball"):
            return

        for user in self.bot.userdms:
            if message.author.id == user:
                return

        if str(message.channel.type) != "private":
            prefix = db.getprefix(message.guild.id)
            db.addchannel(message.channel.id, message.guild.id)
            priority = db.getpriority(message.guild.id)
            mode = db.getmode(message.guild.id)
        else:
            priority = "all"
            prefix = "fbot "
            mode = "default"

        if prefix == "fbot":
            prefix = "fbot "

        if content in [f"<@!{self.bot.user.id}>", f"<@{self.bot.user.id}>"]:
            await message.reply(f"My prefix is `{prefix}`. Use `{prefix}help` for more help")

        elif str(message.channel.type) == "private" or db.getstatus(message.channel.id) == "on":

            if message.attachments:
                response = choice(responses)
                if mode != "default":
                    response = eval(f"modes.{mode}(response)")
                response = modes.capitalise(response)
                await channel.send(response)
                return

            trigger_detected, response = tr.respond(message, priority)
            if trigger_detected:
                response = response.replace("{username}", name)
                response = response.replace("{answer}", choice(answers))
                response = response.replace("{funny}", choice(funny))
                response = modes.sanitise_text(response)

                if mode != "default":
                    response = eval(f"modes.{mode}(response)")
                modes.capitalise(response)

                if len(response) > 2000:
                    response = response[:1997] + "..."
                await channel.send(response)