lapzbot.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Lapzbot_Beta 作者: lap00zza 项目源码 文件源码
def on_message(self, message):
        """

        :param message:
        :return:
        """
        # We don't want Lapzbot to be replying to his
        # own messages right? Also a global count
        # of all the sent messages is used with ?info
        if message.author.id == self.user.id:
            self.redis.incr("LAPZBOT_SENT_MESSAGES")
            return

        # To keep the bad boys from abusing our lovely bot
        blacklist = self.redis.lrange("user_black_list", 0, -1)
        if str(message.author.id).encode() in blacklist:
            return

        # We don't respond to private messages. We are too cool for
        # that
        if message.channel.is_private:
            try:
                await self.loop.create_task(
                    self.send_message(message.author, "Lapzbot can only be used from a server.\n"
                                                      "If you want to know more about Lapzbot, visit "
                                                      "http://lapzbot.xyz/"))
                return
            except discord.DiscordException:
                return

        # Handles the PM mentions. We created this task first as this
        # is the first priority ;)
        await self.loop.create_task(self.commands.pm_mentions_handler(message))

        #  Message Logger hook. This is basically responsible for handling
        # the logging function for Lapzbot.
        await self.loop.create_task(self.commands.log_message(message))

        # Command Parser handles commands directed at Lapzbot. This is
        # responsible for parsing the commands from regular message content
        # and then taking specific actions
        await self.loop.create_task(self.commands.handle_message(message))

        # XP from messages handles giving xp on servers with Ranking enabled
        await self.loop.create_task(self.ranking.ranking_handler(message))

        # Level Up announcer handles the member level up announcements on
        # servers with ranking enabled and announcements enabled
        await self.loop.create_task(self.ranking.level_up_announcer(message))

        # Osu Link Scanner is responsible for parsing osu based links from
        # messages and then taking some specific actions
        await self.loop.create_task(self.osu.parse_message(message))

    # Event handler codes.
    # We handle each event as a task so that it does not
    # end up slowing down the bot and instead do concurrent
    # jobs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号