Пример #1
0
def discord_bot(commands: List[Command]) -> None:
    """Launch the Discord bot"""
    with open("discord.token", "rt", encoding="utf-8") as token_handle:
        token = token_handle.read().strip()

    if not token:
        raise Exception("Unable to load token from token file")

    instance = DiscordBot(commands)
    instance.run(token)
Пример #2
0
def main():
    import os
    import sys

    top_level_dir = os.path.join(os.path.realpath(os.path.dirname(__file__)),
                                 '..')

    sys.path.append(top_level_dir)

    from fastapi.openapi.utils import get_openapi
    import json

    from bot import DiscordBot
    from webserver.server import WebServer

    app = WebServer(discord_bot=DiscordBot(current_dir=top_level_dir, ), ).app

    file_path = os.path.join(top_level_dir, 'docs', 'openapi.json')
    with open(file_path, 'w') as f:
        json.dump(
            get_openapi(
                title=app.title,
                version=app.version,
                openapi_version=app.openapi_version,
                description=app.description,
                routes=app.routes,
            ), f)
Пример #3
0
def main():
    global discord_bot
    discord_bot = DiscordBot(on_connect, on_message)

    config_path = os.path.realpath(
        os.path.join(os.path.dirname(__file__), 'configuration.json'))
    configuration = utils.fetch_json_file_as_dict(config_path)
    discord_bot.setup(configuration)
    discord_bot.subscribe("/hangouts/#")

    while True:
        loop()
Пример #4
0
def run(config_path, no_chdir=False):
    if not no_chdir:
        os.chdir(os.path.dirname(os.path.abspath(__file__)))
    bot = DiscordBot(config_path)
    bot.run()
Пример #5
0
import settings
from loguru import logger
import discord
import discord.ext.commands
from bot import DiscordBot

logger.configure(**settings.LOGGING)

bot = DiscordBot('>')

for module_name in settings.MODULES:
    bot.load_extension('modules.' + module_name)

if __name__ == "__main__":
    bot.run(settings.TOKEN)
Пример #6
0
from bot import DiscordBot
from utils import Utils, ErrorMessages
from validation import Validation

validation = Validation()
utils = Utils()
error_message = ErrorMessages()
bot_token = utils.BOT_TOKEN

while not validation.validate_token(bot_token):
    print(error_message.VALDIDATION_ERROR_MESSAGE)
    userInput = input(utils.USER_TOKEN_QUESTION)

bot = DiscordBot()

##bot.loop.create_task(bot.backgoundTask())
bot.run(bot_token)
Пример #7
0
from webserver import WebServer

logging.basicConfig()

current_dir = os.path.dirname(os.path.realpath(__file__))

global_settings = GlobalSettingsValidator.validate(GLOBAL_SETTINGS)

bot = DiscordBot(
    db=Database(global_settings['DATABASE_URL']),
    i18n=I18nManager(path=global_settings['I18N_FILE']),
    current_dir=current_dir,
    interval_time=global_settings['INTERVAL_TIME'],
    description=global_settings['DESCRIPTION'],
    super_admins=global_settings['SUPER_ADMINS'],
    image_creator=ImageCreator(
        font_loader=FontLoader(global_settings['FONTS']),
        emoji_loader=EmojiLoader(
            emoji_path=global_settings['EMOJIS_PATH'],
            download_emojis=global_settings['DOWNLOAD_EMOJIS'],
            save_downloaded_emojis=global_settings['SAVE_EMOJIS'])),
    logging_level=global_settings['LOGGING_LEVEL'],
)

webserver_static_path = os.path.join(current_dir,
                                     global_settings['WEBSERVER_STATIC_PATH'])
if not os.path.exists(webserver_static_path):
    os.mkdir(webserver_static_path)

build_frontend = False
skip_check = False
Пример #8
0
 def setUpClass(cls):
     cls.bot = DiscordBot()