def run(self, *args, **kwargs):
     # self.ipc.start()
     subprocess.check_output("pip install speedtest-cli", shell=True)
     self.before_invoke(self.start_typing)
     self.utils = utils
     self.deleted_message_cache = LimitedSizeDict()
     self.concurrency = []
     self.color = 0x00ff6a
     self.psutil_process = psutil.Process()
     self._message_cache = {}
     self.prefixes = {}
     self.socket_receive = 0
     self.start_time = time.time()
     self.socket_stats = Counter()
     self.command_counter = 0
     self.commandsusages = Counter()
     self.session = aiohttp.ClientSession(
         headers={
             "User-Agent":
             f"python-requests/2.25.1 The Anime Bot/1.1.0 Python/{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} aiohttp/{aiohttp.__version__}"
         })
     self.mystbin = mystbin.Client(session=self.session)
     self.vacefron_api = vacefron.Client(session=self.session,
                                         loop=self.loop)
     self.dag = Client(api_token, session=self.session, loop=self.loop)
     self.alex = alexflipnote.Client(alex_,
                                     session=self.session,
                                     loop=self.loop)
     self.ball = eight_ball.ball()
     self.zaneapi = aiozaneapi.Client(zane_api)
     for command in self.commands:
         self.command_list.append(str(command))
         self.command_list.extend([alias for alias in command.aliases])
         if isinstance(command, commands.Group):
             for subcommand in command.commands:
                 self.command_list.append(str(subcommand))
                 self.command_list.extend([
                     f"{command} {subcommand_alias}"
                     for subcommand_alias in subcommand.aliases
                 ])
                 if isinstance(subcommand, commands.Group):
                     for subcommand2 in subcommand.commands:
                         self.command_list.append(str(subcommand2))
                         self.command_list.extend([
                             f"{subcommand} {subcommand2_alias}"
                             for subcommand2_alias in subcommand2.aliases
                         ])
                         if isinstance(subcommand2, commands.Group):
                             for subcommand3 in subcommand2.commands:
                                 self.command_list.append(str(subcommand3))
                                 self.command_list.extend([
                                     f"{subcommand2} {subcommand3_alias}"
                                     for subcommand3_alias in
                                     subcommand3.aliases
                                 ])
     super().run(*args, **kwargs)
Beispiel #2
0
        result_prefix = await cur.fetchone()
        if result_prefix:
            return result_prefix
        else:
            return prefix


bot = commands.Bot(command_prefix=_check_prefix, intents=discord.Intents.all())

logging.getLogger('asyncio').setLevel(logging.CRITICAL)

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        bot.load_extension(f'cogs.{filename[:-3]}')

zane = aiozaneapi.Client(ZANE)
bot.zane = zane
bot.remove_command('help')

dagp = Client(DAGPI)
bot.dagp = dagp

headers = {'Authorization': DAGPI}


@tasks.loop(seconds=60)
async def change_status():
    status = f'Sakura Chan watching over {len(bot.guilds)} servers'
    await bot.change_presence(activity=discord.Game(status))

Beispiel #3
0
logger = logging.getLogger("discord")
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w")
handler.setFormatter(
    logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")
)
logger.addHandler(handler)
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")

dagpi = Client(os.getenv("DAGPI_TOKEN"))
cleverbot = ac.Cleverbot(os.getenv("CHATBOT_TOKEN"))


client = aiozaneapi.Client(os.getenv("ZANE_TOKEN"))


async def get_prefix(bot, message):
    if message.guild is None:
        return "kb+"
    if message.guild.id in bot.prefixes.keys():
        return commands.when_mentioned_or(*bot.prefixes[message.guild.id])(bot, message)
    prefixes = await bot.pg.fetchval(
        "select prefixes from prefixes where guild_id = $1", message.guild.id
    )
    bot.prefixes[message.guild.id] = prefixes
    return commands.when_mentioned_or(*prefixes)(bot, message)


class Context(commands.Context):
Beispiel #4
0
bot.version = "15"
START_BAL = 250
token = open("toke.txt", "r").read()
bot.load_extension("jishaku")
hce = bot.get_command("help")
hce.hidden = True
dagpitoken = open("asy.txt", "r").read()
robloxcookie = open("roblox.txt", "r").read()
topastoken = open("top.txt", "r").read()
chatbottoken = open("chat.txt", "r").read()
hypixel = open("hypixel.txt", "r").read()
bot.robloxc = f"{robloxcookie}"
bot.hypixel = f"{hypixel}"
bot.topken = f"{topastoken}"
bot.chatbot = ac.Cleverbot(f"{chatbottoken}")
bot.se = aiozaneapi.Client(f'{open("zane.txt", "r").read()}')
bot.dagpi = Client(dagpitoken)
bot.start_time = time.time()
bot.thresholds = (10, 25, 50, 100)





  



@bot.event
async def on_connect():
    print('bot connected')
Beispiel #5
0
 def __init__(self, bot):
     self.bot = bot
     self.client = aiozaneapi.Client(self.bot.config["zanekey"])
     self.sr_client = sr_api.Client()
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(get_prefix, *args, **kwargs)

        # Prep for embed colour stuff. (Thank you to z03h for this :))
        c = dt.utcnow()
        hours, minutes, seconds = 0, 5, 0

        self.duration = (3600 * hours + 60 * minutes + seconds)
        self.embed_start_dt = dt(c.year, c.month, c.day)
        self.colours = [
            (210, 31, 255),
            (232, 132, 255),
            (216, 192, 255),
            (149, 182, 255),
            (93, 128, 255),
            (128, 84, 255),
            (169, 74, 255),
        ]
        self.per_colour = self.duration // len(self.colours)

        # Vars needed for some functionality.
        self.settings = utils.Settings("config.toml")
        self.maintenance_mode = self.settings["misc"]["maintenance_mode"]
        self.start_time = dt.now()
        self.support_url = "https://discord.gg/tKZbxAF"
        self.invite_url = "https://kal-byte.co.uk/invite/706530005169209386/1580592374"
        self.cmd_usage = 0
        self.announcement = {
            "title": None,
            "message": None
        }

        # Things for cache
        self.verification_config = {}
        self.giveaway_roles = {}
        self.blacklist = {}
        self.ctx_cache = {}
        self.config = {}

        # Stuff that requires the bots loop
        self.loop = asyncio.get_event_loop()
        self.pool = self.loop.run_until_complete(
            asyncpg.create_pool(
                **self.settings["database"]["main"] if os.name != "nt" else self.settings["database"]["beta"])
        )
        self.session = aiohttp.ClientSession(loop=self.loop)

        # Checks to disable functionality for certain things.
        self.add_check(self.command_check)
        self.add_check(self.blacklist_check)

        # Webhooks
        self.error_webhook = discord.Webhook.from_url(
            self.settings["misc"]["error_webhook"],
            adapter=discord.AsyncWebhookAdapter(self.session)
        )
        self.guild_webhook = discord.Webhook.from_url(
            self.settings["misc"]["guild_webhook"],
            adapter=discord.AsyncWebhookAdapter(self.session)
        )

        # Some tasks that prep the bot to be used fully.
        self.loop.create_task(self.do_prep())
        self.loop.create_task(self.chunk_all_guilds())

        # API Wrappers
        self.zane = aiozaneapi.Client(self.settings["keys"]["zane_api"])
Beispiel #7
0
 def __init__(self, bot):
     self.bot = bot
     self.bot.zaneapi = aiozaneapi.Client(zane_api)