Esempio n. 1
0
app.router.add_routes(website.frontend_routes)
app.router.add_routes(website.backend_routes)
app.router.add_routes(website.api_routes)
app.router.add_static('/static',
                      os.getcwd() + '/website/static',
                      append_version=True)

# Add our connections
app['database'] = utils.DatabaseConnection
utils.DatabaseConnection.logger = logger.getChild("db")

# Add our configs
app['config'] = config

# Add our bots
app['bot'] = utils.Bot(config_file=args.config_file,
                       logger=logger.getChild("bot"))

if __name__ == '__main__':
    """Starts the bot (and webserver if specified) and runs forever"""

    loop = app.loop

    # Connect the bot
    logger.info("Logging in bot")
    loop.run_until_complete(app['bot'].login(app['config']['token']))

    # Connect the database
    logger.info("Creating database pool")
    loop.run_until_complete(
        utils.DatabaseConnection.create_pool(app['config']['database']))
Esempio n. 2
0
shard_ids = list(range(args.min, args.max + 1))
if args.shardcount is None and (args.min or args.max):
    logger.critical("You set a min/max shard handler but no shard count")
    exit(1)
if args.shardcount is not None and not (args.min is not None
                                        and args.max is not None):
    logger.critical("You set a shardcount but not min/max shards")
    exit(1)

# Okay cool make the bot object
bot = utils.Bot(
    config_file=args.config_file,
    activity=discord.Game(name="Reconnecting..."),
    status=discord.Status.dnd,
    case_insensitive=True,
    shard_count=args.shardcount,
    shard_ids=shard_ids,
    shard_id=args.min,
    max_messages=100,  # The lowest amount that we can actually cache
    logger=logger.getChild('bot'),
    allowed_mentions=discord.AllowedMentions(everyone=False),
)

# Set loglevel defaults
set_log_level(logger, args.loglevel)
set_log_level(bot.database.logger, args.loglevel)
set_log_level(bot.redis.logger, args.loglevel)
set_log_level('discord', args.loglevel)

# Set loglevels by config
set_log_level(logger, args.loglevel_bot)
set_log_level(bot.database.logger, args.loglevel_database)
Esempio n. 3
0
# Add our connections and their loggers
app['database'] = utils.DatabaseConnection
utils.DatabaseConnection.logger = logger.getChild("db")
utils.DatabaseConnection.logger.setLevel(logging.DEBUG)
app['redis'] = utils.RedisConnection
utils.RedisConnection.logger = logger.getChild("redis")
utils.RedisConnection.logger.setLevel(logging.DEBUG)
app['logger'] = logger
logger.setLevel(logging.DEBUG)

# Add our configs
app['config'] = config
app['gold_config'] = gold_config

# Add our bots
app['bot'] = utils.Bot(config_file=args.config_file,
                       logger=logger.getChild("bot"))
app['gold_bot'] = utils.Bot(config_file=args.gold_config_file,
                            logger=logger.getChild("goldbot"))

if __name__ == '__main__':
    """Starts the bot (and webserver if specified) and runs forever"""

    loop = app.loop

    # Connect the bot
    logger.info("Logging in bot")
    loop.run_until_complete(app['bot'].login(app['config']['token']))
    logger.info("Logging in gold")
    loop.run_until_complete(app['gold_bot'].login(app['gold_config']['token']))

    # Connect the database
Esempio n. 4
0
    presences=True,  # member/user update for games/activities
    guild_messages=True,  # message create/update/delete
    dm_messages=True,  # message create/update/delete
    guild_reactions=True,  # reaction add/remove/clear
    dm_reactions=True,  # reaction add/remove/clear
    guild_typing=True,  # on typing
    dm_typing=True,  # on typing
)

# Okay cool make the bot object
bot = utils.Bot(
    config_file=args.config_file,
    activity=discord.Game(name="Reconnecting..."),
    status=discord.Status.dnd,
    case_insensitive=True,
    shard_count=args.shardcount,
    shard_ids=shard_ids,
    shard_id=args.min,
    logger=logger.getChild('bot'),
    allowed_mentions=discord.AllowedMentions(everyone=False),
    intents=intents,
)

# Set loglevel defaults
set_log_level(logger, args.loglevel)
set_log_level(bot.database.logger, args.loglevel)
set_log_level('discord', args.loglevel)

# Set loglevels by config
set_log_level(logger, args.loglevel_bot)
set_log_level(bot.database.logger, args.loglevel_database)
set_log_level('discord', args.loglevel_discord)
Esempio n. 5
0
shard_ids = list(range(args.min, args.max + 1))
if args.shardcount is None and (args.min or args.max):
    logger.critical("You set a min/max shard handler but no shard count")
    exit(1)
if args.shardcount is not None and not (args.min is not None
                                        and args.max is not None):
    logger.critical("You set a shardcount but not min/max shards")
    exit(1)

# Okay cool make the bot object
bot = utils.Bot(
    config_file=args.config_file,
    activity=discord.Game(name="Reconnecting..."),
    status=discord.Status.dnd,
    case_insensitive=True,
    shard_count=args.shardcount,
    shard_ids=shard_ids,
    shard_id=args.min,
    max_messages=None,
    logger=logger.getChild('bot'),
    fetch_offline_members=True,
)

# Set loglevel defaults
set_log_level(logger, args.loglevel)
set_log_level(bot.database.logger, args.loglevel)
set_log_level(bot.redis.logger, args.loglevel)
set_log_level('discord', args.loglevel)

# Set loglevels by config
set_log_level(logger, args.loglevel_bot)
set_log_level(bot.database.logger, args.loglevel_database)