Esempio n. 1
0
 def __init__(self, client):
     self.client = client
     self.token = dbltoken  # set this to your DBL token
     self.dblpy = dbl.DBLClient(
         self.client, self.token, autopost=True
     )  # Autopost will post your guild count every 30 minutes
     print("uploaded top.gg")
Esempio n. 2
0
    def __init__(self, bot):
        self.bot = bot

        with open("./lib/bot/topgg.txt", "r", encoding="utf-8") as tf:
            self.token = tf.read() # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
        print("\nTop.gg updated")
Esempio n. 3
0
    def __init__(self, bot):
        self.bot = bot
        self.token = bot.config.DBL_TOKEN
        self.bot.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=bot.config.DBL_password, webhook_port=5435, autopost=True)

        self.help_icon = ""
        self.big_icon = ""
Esempio n. 4
0
 def __init__(self, bot, dbl_token):
     """ Set attributes and get DBL client object. """
     self.bot = bot
     self.dbl_token = dbl_token
     self.dbl_client = dbl.DBLClient(self.bot, self.dbl_token)
     self.topgg_url = 'https://top.gg/bot/{self.bot.user.id}'
     self.update_stats.start()
Esempio n. 5
0
 async def on_red_api_tokens_update(self, service_name: str,
                                    api_tokens: Mapping[str, str]):
     if service_name != "dbl":
         return
     try:
         if self.dbl:
             self.dbl.close()
         config = await self.config.all()
         client = dbl.DBLClient(
             bot=self.bot,
             token=api_tokens.get("api_key"),
             session=self.session,
             webhook_port=config["webhook_port"],
             webhook_auth=config["webhook_auth"],
         )
         await client.get_guild_count()
     except (dbl.Unauthorized, dbl.UnauthorizedDetected):
         await client.close()
         return await self.bot.send_to_owners(
             "[DblTools cog]\n" + error_message.format(
                 _("A wrong token has been set for dbltools cog.\n\n")))
     except dbl.NotFound:
         await client.close()
         return await self.bot.send_to_owners(
             _("[DblTools cog]\nThis bot seems doesn't seems be validated on Top.gg. Please try again with a validated bot."
               ))
     self.dbl = client
Esempio n. 6
0
    def __init__(self, bot):
        self.bot = bot

        self.bot.dbl = dbl.DBLClient(self.bot,
                                     config.DBL_TOKEN,
                                     session=self.bot.session,
                                     autopost=True)
Esempio n. 7
0
    def __init__(self, bot):
        self.bot = bot
        self.token = dbltoken
        self.auth = dblauth
        self.dblpy = dbl.DBLClient(self.bot,
                                   self.token,
                                   webhook_path='/dblwebhook',
                                   webhook_auth=dblauth,
                                   webhook_port=5000)


        async def get_supporters():

            await bot.wait_until_ready()

            guild = bot.get_guild(581084433646616576)

            role = guild.get_role(724522070960111626)
            supporters = []

            for member in guild.members:
                if role in member.roles:
                    supporters.append(member)

            self.supporters = supporters
        bot.loop.create_task(get_supporters())
Esempio n. 8
0
 async def on_red_api_tokens_update(self, service_name: str,
                                    api_tokens: Mapping[str, str]):
     if service_name != "dbl":
         return
     try:
         if self.dbl:
             self.dbl.close()
         client = dbl.DBLClient(self.bot,
                                api_tokens.get("api_key"),
                                session=self.session)
         await client.get_guild_count()
     except (dbl.Unauthorized, dbl.UnauthorizedDetected):
         await client.close()
         return await self.bot.send_to_owners(
             "[DblTools cog]\n" + error_message.format(
                 _("A wrong token has been set for dbltools cog.\n\n")))
     except dbl.NotFound:
         await client.close()
         return await self.bot.send_to_owners(
             _("[DblTools cog]\nThis bot seems doesn't seems be validated on Top.gg. Please try again with a validated bot."
               ))
     except dbl.errors.HTTPException:
         await client.close()
         return await self.bot.send_to_owners(
             _("[DblTools cog]\nFailed to contact Top.gg API. Please try again later."
               ))
     self.dbl = client
     self._ready_event.set()
Esempio n. 9
0
 def __init__(self, bot):
     if os.getenv("DEBUG") == "true":
         print("Running in dev mode!")
     else:
         self.bot = bot
         self.token = os.getenv("DBL_TOKEN")
         self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
Esempio n. 10
0
    def __init__(self, bot):
        self.bot = bot
        self.token = tokens.DBL # set this to your DBL token
        self.bot.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=self.token, webhook_port=5000)

        self.icon = ""
        self.big_icon = ""
Esempio n. 11
0
    def __init__(self, bot):
        self.bot = bot

        self.dblpy = dbl.DBLClient(self.bot, self.bot.dbl_keys[0],
                                   webhook_path="/updoot_topgg",
                                   webhook_auth=self.bot.dbl_keys[1],
                                   webhook_port=3209, autopost=True)
Esempio n. 12
0
 def __init__(self, client):
     self.client = client
     with open("./config.json", "r") as f:
         config = json.load(f)
     self.token = config["topToken"]
     self.dblpy = dbl.DBLClient(self.client, self.token)
     self.update_stats.start()
Esempio n. 13
0
 def __init__(self, bot):
     self.bot = bot
     self.token = self.bot.api_data[
         'dbl_token']  # set this to your DBL token
     self.dblpy = dbl.DBLClient(
         self.bot, self.token, autopost=True
     )  # Autopost will post your guild count every 30 minutes
Esempio n. 14
0
    def __init__(self, bot):
        self.bot = bot
        self.token = config.DBLToken  # set this to your DBL token
        self.bot.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)

        self.help_icon = ""
        self.big_icon = ""
Esempio n. 15
0
    def __init__(self):
        super().__init__(
            command_prefix=commands.when_mentioned_or(config.DISCORD_PREFIX),
            reconnect=True,
        )
        self.loop = asyncio.get_event_loop()
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.config = config

        self.db = None
        self.db_ready = False

        self.stats = {}
        self.owner_ids = {238356301439041536}
        self.user_blacklist = []
        self.guild_blacklist = []

        self.dblpy = dbl.DBLClient(self,
                                   config.DBL_TOKEN,
                                   webhook_path="/dblwebhook",
                                   webhook_auth=config.DBL_TOKEN,
                                   webhook_port=5000)

        for extension in EXTENSIONS:
            try:
                self.load_extension(extension)
                print(f"[EXT] Success - {extension}")
            except commands.ExtensionNotFound:
                print(f"[EXT] Failed - {extension}")
Esempio n. 16
0
    def __init__(self, client=None):
        # set up parser to config through our .ini file with our discordbots.org api token
        config = configparser.ConfigParser()
        api_token_path = Path("tokens/token_dbo_api.ini"
                              )  # use forward slash "/" for path directories
        # confirm the token is located in the above path, then setup DBL client and execute update_stats
        if api_token_path.is_file():
            config.read(api_token_path)
            # we now have the client's token
            token = config.get("DBL_API", "token")
            self.token = token  # set this to your DBL token

            # only setup a loop to update server count to API when client is passed in constructor
            if client:
                self.client = client
                self.dblpy = dbl.DBLClient(self.client,
                                           self.token,
                                           autopost=True)
        # if the file doesn't exist with the api token, do not attempt to use discordbots.org API
        else:
            logger.info("\nWarning: discordbots.org token not found at: ",
                        api_token_path)
            logger.info(
                "client will continue to run without DiscordBotsOrgApi support."
            )
Esempio n. 17
0
    def _run_dbl_stats(self) -> None:
        if self.dbl_key != "":
            dbl_client = dbl.DBLClient(self.bot, self.dbl_key)

            async def _update_stats(client) -> None:
                last_count = 0
                while not client.bot.is_closed():
                    try:
                        if client.guild_count() != last_count:
                            await client.post_guild_count()
                            self.log.debug(
                                f"[SERVER COUNT] Posted server count "
                                f"({client.guild_count()})"
                            )
                            await self.bot.change_presence(
                                activity=discord.Activity(
                                    type=discord.ActivityType.listening,
                                    name=".help on {} servers".format(
                                        client.guild_count()
                                    ),
                                )
                            )
                            last_count = client.guild_count()
                    except Exception as raised_exception:
                        self.log.warning(
                            logging_manager.debug_info(str(raised_exception))
                        )
                    await asyncio.sleep(1800)

            self.bot.loop.create_task(_update_stats(dbl_client))
Esempio n. 18
0
    def __init__(self, bot):
        self.bot = bot

        self.dblpy = dbl.DBLClient(
            self.bot, os.environ.get('topgg'), autopost=True
        )  # Autopost will post your guild count every 30 minutes
        print("\nTop.gg updated")
Esempio n. 19
0
    def run_dbl_stats(self):
        if self.dbl_key != "":
            dbl_client = dbl.DBLClient(self.bot, self.dbl_key)

            async def update_stats(client):
                while not client.bot.is_closed():
                    try:
                        await client.post_guild_count()
                        self.log.debug(
                            "[SERVER COUNT] Posted server count ({})".format(
                                client.guild_count()
                            )
                        )
                        await self.bot.change_presence(
                            activity=discord.Activity(
                                type=discord.ActivityType.listening,
                                name=".help on {} servers".format(
                                    client.guild_count()
                                ),
                            )
                        )
                    except Exception as e:
                        self.log.warning(logging_manager.debug_info(e))
                    await asyncio.sleep(1800)

            self.bot.loop.create_task(update_stats(dbl_client))
Esempio n. 20
0
 def __init__(self, bot):
     self.bot : commands.Bot = bot
     self.config = self.bot.config["top_gg"]
     if self.config["enabled"]:
         self.token = self.config["token"] # set this to your DBL token
         self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
     self.check_votes.start()
Esempio n. 21
0
 async def initialize(self):
     await self.bot.wait_until_ready()
     key = (await self.bot.get_shared_api_tokens("dbl")).get("api_key")
     try:
         client = dbl.DBLClient(self.bot, key, session=self.session)
         await client.get_guild_count()
     except (dbl.Unauthorized, dbl.UnauthorizedDetected):
         await client.close()
         return await self.bot.send_to_owners(
             "[DblTools cog]\n" + error_message.format(intro_msg)
         )
     except dbl.NotFound:
         await client.close()
         return await self.bot.send_to_owners(
             _(
                 "[DblTools cog]\nThis bot seems doesn't seems be validated on Top.gg. Please try again with a validated bot."
             )
         )
     except dbl.errors.HTTPException:
         await client.close()
         return await self.bot.send_to_owners(
             _("[DblTools cog]\nFailed to contact Top.gg API. Please try again later.")
         )
     self.dbl = client
     self._ready_event.set()
Esempio n. 22
0
    def __init__(self, bot):
        self.bot = bot
        self.token = token['dbl']
        self.guild = config['support']
        self.debug = config['debug']

        self.dblpy = dbl.DBLClient(self.bot, self.token)
Esempio n. 23
0
    def __init__(self, bot):
        self.bot = bot

        # tokens for updating stats on bot listings
        with open("./data/botsggtoken.txt") as bots_gg_token:
            self.DBL_CLIENT = dbl.DBLClient(self.bot,
                                            bots_gg_token.readline(),
                                            autopost=True)
Esempio n. 24
0
 def __init__(self, bot):
     self.bot = bot
     self.token = dbltoken
     self.dblpy = dbl.DBLClient(self.bot,
                                self.token,
                                webhook_path='/dblwebhook',
                                webhook_auth='loliamtesting',
                                webhook_port=5000)
Esempio n. 25
0
 def __init__(self, client):
     self.client = client
     self.token = os.environ["dev_dbz_dbl_token"]
     self.dbl = dbl.DBLClient(self.client,
                              self.token,
                              webhook_path="/dblwebhook",
                              webhook_port=8152,
                              webhook_auth=self.token)
Esempio n. 26
0
 def run_live_bot(self):
     """Run Production Ver. of the the bot."""
     module.keys.top_gg = dbl.DBLClient(ex.client,
                                        module.keys.top_gg_key,
                                        autopost=True)  # set top.gg client
     self.start_up()
     self.start_loops()
     ex.client.run(module.keys.client_token)
Esempio n. 27
0
 def __init__(self, bot):
     self.bot = bot
     self.token = "DBLTOKEN"
     self.dblpy = dbl.DBLClient(self.bot,
                                self.token,
                                webhook_path='/dblwebhook',
                                webhook_auth='PASSWORD',
                                webhook_port=2737)
Esempio n. 28
0
 def __init__(self, bot):
     self.bot = bot
     self.token = os.getenv('top_token')  # set this to your DBL token
     self.dblpy = dbl.DBLClient(self.bot,
                                self.token,
                                webhook_path='/',
                                webhook_auth=self.token,
                                webhook_port=5000)
 def __init__(self, bot):
     self.bot = bot
     self.token = 'API KEY'  # set this to your DBL token
     self.dblpy = dbl.DBLClient(self.bot,
                                self.token,
                                webhook_path='/dblwebhook',
                                webhook_auth='password',
                                webhook_port=5000)
Esempio n. 30
0
 def __init__(self, bot):
     self.bot = bot
     self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijc4MjI3MDcxNzE2ODU4MjY3OCIsImJvdCI6dHJ1ZSwiaWF0IjoxNjEyODEwMTk1fQ.ckHiEC22RnUjafwnnh5omIfcJBqfS4cSbGIN3eLSfVU'  # set this to your DBL token
     self.dblpy = dbl.DBLClient(self.bot,
                                self.token,
                                webhook_path='/dblwebhook',
                                webhook_auth='password',
                                webhook_port=5000)