2019-04-01 10:33:20 +00:00
|
|
|
import os
|
|
|
|
import asyncio
|
2019-04-14 21:31:24 +00:00
|
|
|
import logging
|
2019-04-19 17:43:24 +00:00
|
|
|
from royalnet.bots import DiscordBot, DiscordConfig, TelegramBot, TelegramConfig
|
2019-04-09 09:15:27 +00:00
|
|
|
from royalnet.commands import *
|
2019-04-01 10:33:20 +00:00
|
|
|
from royalnet.commands.debug_create import DebugCreateCommand
|
2019-04-04 15:39:38 +00:00
|
|
|
from royalnet.commands.error_handler import ErrorHandlerCommand
|
2019-04-19 00:29:39 +00:00
|
|
|
from royalnet.network import RoyalnetServer, RoyalnetConfig
|
2019-04-18 14:09:02 +00:00
|
|
|
from royalnet.database import DatabaseConfig
|
2019-04-11 17:04:49 +00:00
|
|
|
from royalnet.database.tables import Royal, Telegram, Discord
|
2019-04-01 10:33:20 +00:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
2019-04-15 08:39:19 +00:00
|
|
|
log = logging.root
|
2019-04-19 17:43:24 +00:00
|
|
|
stream_handler = logging.StreamHandler()
|
|
|
|
stream_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{")
|
|
|
|
log.addHandler(stream_handler)
|
2019-04-19 00:29:39 +00:00
|
|
|
logging.getLogger("royalnet.bots.generic").setLevel(logging.DEBUG)
|
2019-04-19 17:43:24 +00:00
|
|
|
logging.getLogger("royalnet.bots.discord").setLevel(logging.DEBUG)
|
|
|
|
logging.getLogger("royalnet.bots.telegram").setLevel(logging.DEBUG)
|
2019-04-14 21:31:24 +00:00
|
|
|
|
2019-04-03 17:31:20 +00:00
|
|
|
commands = [PingCommand, ShipCommand, SmecdsCommand, ColorCommand, CiaoruoziCommand, DebugCreateCommand, SyncCommand,
|
2019-04-09 15:00:14 +00:00
|
|
|
AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand,
|
2019-04-19 22:22:07 +00:00
|
|
|
KvrollCommand, VideoinfoCommand, SummonCommand, PlayCommand, SkipCommand]
|
2019-04-01 10:33:20 +00:00
|
|
|
|
2019-04-19 00:29:39 +00:00
|
|
|
address, port = "localhost", 1234
|
|
|
|
|
|
|
|
master = RoyalnetServer(address, port, "sas")
|
|
|
|
ds_bot = DiscordBot(discord_config=DiscordConfig(os.environ["DS_AK"]),
|
|
|
|
royalnet_config=RoyalnetConfig(f"ws://{address}:{port}", "sas"),
|
|
|
|
database_config=DatabaseConfig(os.environ["DB_PATH"], Royal, Discord, "discord_id"),
|
|
|
|
commands=commands,
|
|
|
|
error_command=ErrorHandlerCommand)
|
2019-04-19 17:43:24 +00:00
|
|
|
tg_bot = TelegramBot(telegram_config=TelegramConfig(os.environ["TG_AK"]),
|
|
|
|
royalnet_config=RoyalnetConfig(f"ws://{address}:{port}", "sas"),
|
|
|
|
database_config=DatabaseConfig(os.environ["DB_PATH"], Royal, Telegram, "tg_id"),
|
|
|
|
commands=commands,
|
|
|
|
error_command=ErrorHandlerCommand)
|
2019-04-15 08:39:19 +00:00
|
|
|
loop.run_until_complete(master.run())
|
2019-04-19 17:43:24 +00:00
|
|
|
loop.create_task(tg_bot.run())
|
2019-04-11 22:55:35 +00:00
|
|
|
loop.create_task(ds_bot.run())
|
2019-04-01 10:33:20 +00:00
|
|
|
print("Starting loop...")
|
|
|
|
loop.run_forever()
|