mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Start work on the new runbot script
This commit is contained in:
parent
db954f97b8
commit
b1ee018254
6 changed files with 65 additions and 127 deletions
|
@ -19,3 +19,4 @@ markdown2>=2.3.8
|
|||
mcstatus>=2.2.1
|
||||
sortedcontainers>=2.1.0
|
||||
sentry-sdk>=0.11.1
|
||||
click>=7.0
|
||||
|
|
|
@ -2,4 +2,12 @@ from .debug_error import DebugErrorCommand
|
|||
from .debug_keyboard import DebugKeyboardCommand
|
||||
from .debug_invoking import DebugInvokingCommand
|
||||
|
||||
__all__ = ["DebugErrorCommand", "DebugKeyboardCommand", "DebugInvokingCommand"]
|
||||
|
||||
commands = [
|
||||
DebugErrorCommand,
|
||||
DebugKeyboardCommand,
|
||||
DebugInvokingCommand,
|
||||
]
|
||||
|
||||
|
||||
__all__ = [command.__name__ for command in commands]
|
||||
|
|
|
@ -26,27 +26,31 @@ from .trivia import TriviaCommand
|
|||
from .mm import MmCommand
|
||||
from .zawarudo import ZawarudoCommand
|
||||
|
||||
__all__ = [
|
||||
"CiaoruoziCommand",
|
||||
"ColorCommand",
|
||||
"CvCommand",
|
||||
"DiarioCommand",
|
||||
"Mp3Command",
|
||||
"PauseCommand",
|
||||
"PingCommand",
|
||||
"PlayCommand",
|
||||
"PlaymodeCommand",
|
||||
"QueueCommand",
|
||||
"RageCommand",
|
||||
"ReminderCommand",
|
||||
"ShipCommand",
|
||||
"SkipCommand",
|
||||
"SmecdsCommand",
|
||||
"SummonCommand",
|
||||
"VideochannelCommand",
|
||||
"DnditemCommand",
|
||||
"DndspellCommand",
|
||||
"TriviaCommand",
|
||||
"MmCommand",
|
||||
"ZawarudoCommand"
|
||||
|
||||
commands = [
|
||||
CiaoruoziCommand,
|
||||
ColorCommand,
|
||||
CvCommand,
|
||||
DiarioCommand,
|
||||
Mp3Command,
|
||||
PauseCommand,
|
||||
PingCommand,
|
||||
PlayCommand,
|
||||
PlaymodeCommand,
|
||||
QueueCommand,
|
||||
RageCommand,
|
||||
ReminderCommand,
|
||||
ShipCommand,
|
||||
SkipCommand,
|
||||
SmecdsCommand,
|
||||
SummonCommand,
|
||||
VideochannelCommand,
|
||||
DnditemCommand,
|
||||
DndspellCommand,
|
||||
TriviaCommand,
|
||||
MmCommand,
|
||||
ZawarudoCommand
|
||||
]
|
||||
|
||||
|
||||
__all__ = [command.__name__ for command in commands]
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
"""The production Royalnet, active at @royalgamesbot on Telegram and Royalbot on Discord."""
|
||||
|
||||
import os
|
||||
import asyncio
|
||||
import logging
|
||||
import sentry_sdk
|
||||
from royalnet.bots import DiscordBot, DiscordConfig, TelegramBot, TelegramConfig
|
||||
from royalnet.commands.royalgames import *
|
||||
from royalnet.commands.debug import *
|
||||
from royalnet.network import RoyalnetServer, RoyalnetConfig
|
||||
from royalnet.database import DatabaseConfig
|
||||
from royalnet.database.tables import Royal, Telegram, Discord
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
log = logging.getLogger("royalnet.bots")
|
||||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{")
|
||||
log.addHandler(stream_handler)
|
||||
|
||||
|
||||
sentry_dsn = os.environ.get("SENTRY_DSN")
|
||||
|
||||
# noinspection PyUnreachableCode
|
||||
if __debug__:
|
||||
commands = [
|
||||
CiaoruoziCommand,
|
||||
ColorCommand,
|
||||
CvCommand,
|
||||
DiarioCommand,
|
||||
Mp3Command,
|
||||
PauseCommand,
|
||||
PingCommand,
|
||||
PlayCommand,
|
||||
PlaymodeCommand,
|
||||
QueueCommand,
|
||||
RageCommand,
|
||||
ReminderCommand,
|
||||
ShipCommand,
|
||||
SkipCommand,
|
||||
SmecdsCommand,
|
||||
SummonCommand,
|
||||
VideochannelCommand,
|
||||
TriviaCommand,
|
||||
MmCommand,
|
||||
ZawarudoCommand,
|
||||
DebugInvokingCommand
|
||||
]
|
||||
log.setLevel(logging.DEBUG)
|
||||
else:
|
||||
commands = [
|
||||
CiaoruoziCommand,
|
||||
ColorCommand,
|
||||
CvCommand,
|
||||
DiarioCommand,
|
||||
Mp3Command,
|
||||
PauseCommand,
|
||||
PingCommand,
|
||||
PlayCommand,
|
||||
PlaymodeCommand,
|
||||
QueueCommand,
|
||||
RageCommand,
|
||||
ReminderCommand,
|
||||
ShipCommand,
|
||||
SkipCommand,
|
||||
SmecdsCommand,
|
||||
SummonCommand,
|
||||
VideochannelCommand,
|
||||
DnditemCommand,
|
||||
DndspellCommand,
|
||||
TriviaCommand,
|
||||
MmCommand,
|
||||
ZawarudoCommand
|
||||
]
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
address, port = "127.0.0.1", 1234
|
||||
|
||||
print("Starting master...")
|
||||
master = RoyalnetServer(address, port, os.environ["MASTER_KEY"])
|
||||
loop.run_until_complete(master.start())
|
||||
|
||||
print("Starting bots...")
|
||||
ds_bot = DiscordBot(discord_config=DiscordConfig(os.environ["DS_AK"]),
|
||||
royalnet_config=RoyalnetConfig(f"ws://{address}:{port}", os.environ["MASTER_KEY"]),
|
||||
database_config=None,
|
||||
sentry_dsn=sentry_dsn,
|
||||
commands=commands)
|
||||
tg_bot = TelegramBot(telegram_config=TelegramConfig(os.environ["TG_AK"]),
|
||||
royalnet_config=RoyalnetConfig(f"ws://{address}:{port}", os.environ["MASTER_KEY"]),
|
||||
database_config=None,
|
||||
sentry_dsn=sentry_dsn,
|
||||
commands=commands)
|
||||
loop.create_task(tg_bot.run())
|
||||
loop.create_task(ds_bot.run())
|
||||
|
||||
print("Enabled commands:")
|
||||
for command in commands:
|
||||
print(f"{command.name} - {command.description}")
|
||||
|
||||
print("Running loop...")
|
||||
loop.run_forever()
|
26
royalnet/run.py
Normal file
26
royalnet/run.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import click
|
||||
import typing
|
||||
import royalnet as r
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--telegram/--no-telegram", default=None,
|
||||
help="Enable/disable the Telegram module.")
|
||||
@click.option("--discord/--no-discord", default=None,
|
||||
help="Enable/disable the Discord module.")
|
||||
@click.option("--database", type=str, default=None,
|
||||
help="The PostgreSQL database path.")
|
||||
@click.option("--commands", type=str, multiple=True, default=[],
|
||||
help="The names of the command pack modules that should be imported.")
|
||||
@click.option("--network", type=str, default=None,
|
||||
help="The Royalnet master server uri and password, separated by a pipe.")
|
||||
def run(telegram: typing.Optional[bool],
|
||||
discord: typing.Optional[bool],
|
||||
database: typing.Optional[str],
|
||||
commands: typing.List[str],
|
||||
network: typing.Optional[str]):
|
||||
...
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
3
setup.py
3
setup.py
|
@ -30,7 +30,8 @@ setuptools.setup(
|
|||
"markdown2>=2.3.8",
|
||||
"mcstatus>=2.2.1",
|
||||
"sortedcontainers>=2.1.0",
|
||||
"sentry-sdk>=0.11.1"],
|
||||
"sentry-sdk>=0.11.1",
|
||||
"click>=7.0"],
|
||||
python_requires=">=3.7",
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
|
|
Loading…
Reference in a new issue