Ejemplo n.º 1
0
    def on_server_join(self, server):
        server_count = util.get_server_count()
        if server_count % 25 == 0:
            # Announce every 100 servers (for now)
            yield from util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!!!1111" %
                server_count)

        util.logger.info("Joined server name: %s id: %s", server.name,
                         server.id)

        yield from util.set_up_roles(server)

        server_stats = self.server_stats(server)
        yield from util.duelogger.info(
            ("DueUtil has joined the server **" +
             util.ultra_escape_string(server.name) + "**!\n" +
             "``Member count →`` " + str(server_stats["member_count"]) + "\n" +
             "``Bot members →``" + str(server_stats["bot_count"]) + "\n" +
             ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new server admins.
        yield from self.send_message(
            server.default_channel, ":wave: __Thanks for adding me!__\n" +
            "If you would like to customize me to fit your " +
            "server take a quick look at the admins " +
            "guide at <https://dueutil.tech/howto/#adming>.\n" +
            "It shows how to change the command prefix here, and set which " +
            "channels I or my commands can be used in (along with a bunch of other stuff)."
        )
        # Update stats
        yield from servercounts.update_server_count(self)
Ejemplo n.º 2
0
    async def on_guild_join(self, guild):
        server_count = util.get_server_count()
        if server_count % 250 == 0:
            await util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!1!111!\n@everyone"
                % server_count)

        util.logger.info("Joined guild name: %s id: %s", guild.name, guild.id)
        try:
            await util.set_up_roles(guild)
        except discord.Forbidden:
            util.logger.warning("Unable to setup role for new server")
        server_stats = self.server_stats(guild)
        await util.duelogger.info(
            ("BattleBanana has joined the guild **" +
             util.ultra_escape_string(guild.name) + "**!\n" +
             "``Member count →`` " + str(guild.member_count) + "\n" +
             "``Bot members →``" + str(server_stats["bot_count"]) + "\n" +
             ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new guild admins.
        try:
            audit = await guild.audit_logs(
                action=discord.AuditLogAction.bot_add).find(self.who_added)
            user = audit.user

            await user.create_dm()
            await user.send(
                ":wave: __Thanks for adding me!__\n" +
                "If you would like to customize me to fit your " +
                "guild take a quick look at the admins " +
                "guide at <https://battlebanana.xyz/howto/#adming>.\n" +
                "It shows how to change the command prefix here, and set which "
                +
                "channels I or my commands can be used in (along with a bunch of other stuff)."
            )
        except discord.Forbidden:
            for channel in guild.channels:
                if isinstance(channel, discord.TextChannel):
                    try:
                        await channel.send(
                            ":wave: __Thanks for adding me!__\n" +
                            "If you would like to customize me to fit your " +
                            "guild take a quick look at the admins " +
                            "guide at <https://battlebanana.xyz/howto/#adming>.\n"
                            +
                            "It shows how to change the command prefix here, and set which "
                            +
                            "channels I or my commands can be used in (along with a bunch of other stuff)."
                        )
                        break
                    except discord.Forbidden:
                        continue
        except Exception as e:
            util.logger.warning("Unable to send on join message: %s", e)

        # Update stats
        await servercounts.update_server_count(self)
Ejemplo n.º 3
0
 def on_ready(self):
     shard_number = shard_clients.index(self) + 1
     server_count = util.get_server_count()
     help_status = discord.Game(name="dueutil.org in %d servers!" %
                                (server_count))
     yield from self.change_presence(game=help_status, afk=False)
     util.logger.info(
         "\nLogged in shard %d as\n%s\nWith account @%s ID:%s \n-------",
         shard_number, self.name, self.user.name, self.user.id)
     self.loaded = True
     if loaded():
         yield from util.duelogger.bot("DueUtil has *(re)*started\n" +
                                       "Bot version → ``%s``" %
                                       gconf.VERSION)
     dbltoken = ""
     url = "https://top.gg/api/bots/" + "496480755728384002" + "/stats"
     headers = {"Authorization": dbltoken}
     payload = {"server_count": util.get_server_count()}
     requests.post(url, data=json.dumps(payload), headers=headers)
Ejemplo n.º 4
0
    def on_server_join(self, server):
        server_count = util.get_server_count()
        if server_count % 10000 == 0:
            # Announce every 100 servers (for now)
            yield from util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!!!1111" %
                server_count)

        yield from util.set_up_roles(server)

        server_stats = self.server_stats(server)
        if random.randint(1, 3) == 2:
            util.logger.info("Joined server name: %s id: %s", server.name,
                             server.id)
            yield from util.duelogger.info(
                ("DueUtil has joined the server **" +
                 util.ultra_escape_string(server.name) + "**!\n" +
                 "``Member count →`` " + str(server_stats["member_count"]) +
                 "\n" + "``Bot members →``" + str(server_stats["bot_count"]) +
                 "\n" +
                 ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new server admins.
        yield from self.send_message(
            server.owner, ":wave: __Thanks for adding me!__\n" +
            "If you would like to customize me to fit your " +
            "server take a quick look at the admin " +
            "guide at <https://dueutil.weebly.com/theelgirlsdueutil.html>.\n" +
            "It shows how to change the command prefix here, and set which " +
            "channels I or my commands can be used in (along with a bunch of other stuff).\n"
            +
            "If you still need help, you can use ``!requestsupport cnf``, and a support person will join your server as soon as they can for in-person help!"
        )
        dbltoken = ""
        url = "https://top.gg/api/bots/" + "496480755728384002" + "/stats"
        headers = {"Authorization": dbltoken}
        payload = {"server_count": util.get_server_count()}
        requests.post(url, data=json.dumps(payload), headers=headers)
Ejemplo n.º 5
0
 def on_server_remove(self, server):
     #        for collection in dbconn.db.collection_names():
     #            if collection != "Player":
     #                dbconn.db[collection].delete_many({'_id': {'$regex': '%s.*' % server.id}})
     #                dbconn.db[collection].delete_many({'_id': server.id})
     #            if random.randint(1, 100) == 100:
     #                yield from util.duelogger.info("DueUtil been removed from the server **%s**"
     #                                               % util.ultra_escape_string(server.name))
     dbltoken = ""
     url = "https://top.gg/api/bots/" + "496480755728384002" + "/stats"
     headers = {"Authorization": dbltoken}
     payload = {"server_count": util.get_server_count()}
     requests.post(url, data=json.dumps(payload), headers=headers)
Ejemplo n.º 6
0
    def on_message(self, message):
        if (message.author == self.user or message.channel.is_private
                or not loaded()):
            return
        try:
            if message.author.bot:
                return
        except:
            return
        if 0 <= (int(time.time()) % 900) <= 1.5:
            shard_number = shard_clients.index(self) + 1
            server_count = util.get_server_count()
            help_status = discord.Game(name="dueutil.org in %d servers!" %
                                       (server_count))
            yield from self.change_presence(game=help_status, afk=False)
        mentions_self_regex = "<@.?" + self.user.id + ">"
        if re.match("^" + mentions_self_regex, message.content):
            message.content = re.sub(
                mentions_self_regex + "\s*",
                dueserverconfig.server_cmd_key(message.server),
                message.content)
#        try:
        yield from events.on_message_event(message)