-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16bec04
commit bd564aa
Showing
13 changed files
with
1,649 additions
and
1,649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"""HC-TCG online bot.""" | ||
"""HC-TCG online bot.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
"""Run the bot.""" | ||
|
||
from importlib import import_module | ||
from os import listdir, path | ||
from time import time | ||
|
||
from apscheduler.schedulers.asyncio import AsyncIOScheduler | ||
from interactions import Client, listen | ||
|
||
from bot.config import CONFIG | ||
from bot.util import ServerManager | ||
|
||
start = time() | ||
|
||
|
||
class Bot(Client): | ||
"""Slightly modified discord client.""" | ||
|
||
@listen() | ||
async def on_ready(self: "Bot") -> None: | ||
"""Handle bot starting.""" | ||
await server_manager.reload_all_generators() | ||
|
||
await bot.change_presence() | ||
scheduler.start() | ||
|
||
print(f"Bot started in {round(time()-start, 2)}s") | ||
|
||
@listen() | ||
async def on_disconnect(self: "Bot") -> None: | ||
"""Handle bot disconnection.""" | ||
await server_manager.close_all_sessions() | ||
scheduler.shutdown() | ||
|
||
|
||
bot = Bot() | ||
|
||
scheduler = AsyncIOScheduler() | ||
|
||
servers = [] | ||
for file in listdir("servers"): | ||
if not path.isfile(f"servers/{file}"): | ||
continue | ||
servers.append(import_module(f"servers.{file.removesuffix(".py")}").server) | ||
|
||
server_manager = ServerManager(bot, servers) | ||
|
||
bot.load_extensions("bot\\exts", manager=server_manager, scheduler=scheduler) | ||
|
||
bot.start(CONFIG.SECRET) | ||
"""Run the bot.""" | ||
|
||
from importlib import import_module | ||
from os import listdir, path | ||
from time import time | ||
|
||
from apscheduler.schedulers.asyncio import AsyncIOScheduler | ||
from interactions import Client, listen | ||
|
||
from bot.config import CONFIG | ||
from bot.util import ServerManager | ||
|
||
start = time() | ||
|
||
|
||
class Bot(Client): | ||
"""Slightly modified discord client.""" | ||
|
||
@listen() | ||
async def on_ready(self: "Bot") -> None: | ||
"""Handle bot starting.""" | ||
await server_manager.reload_all_generators() | ||
|
||
await bot.change_presence() | ||
scheduler.start() | ||
|
||
print(f"Bot started in {round(time()-start, 2)}s") | ||
|
||
@listen() | ||
async def on_disconnect(self: "Bot") -> None: | ||
"""Handle bot disconnection.""" | ||
await server_manager.close_all_sessions() | ||
scheduler.shutdown() | ||
|
||
|
||
bot = Bot() | ||
|
||
scheduler = AsyncIOScheduler() | ||
|
||
servers = [] | ||
for file in listdir("servers"): | ||
if not path.isfile(f"servers/{file}"): | ||
continue | ||
servers.append(import_module(f"servers.{file.removesuffix(".py")}").server) | ||
|
||
server_manager = ServerManager(bot, servers) | ||
|
||
bot.load_extensions("bot\\exts", manager=server_manager, scheduler=scheduler) | ||
|
||
bot.start(CONFIG.SECRET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
"""Load environment config.""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import dotenv | ||
|
||
|
||
class Config: | ||
"""Load environement variables as class.""" | ||
|
||
def __init__(self: Config) -> None: | ||
"""Load environement variables as class.""" | ||
dotenv.load_dotenv() | ||
|
||
env = os.environ | ||
|
||
self.SECRET: str = env.get("DISCORD_SECRET") or "" | ||
|
||
|
||
CONFIG = Config() | ||
"""Load environment config.""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import dotenv | ||
|
||
|
||
class Config: | ||
"""Load environement variables as class.""" | ||
|
||
def __init__(self: Config) -> None: | ||
"""Load environement variables as class.""" | ||
dotenv.load_dotenv() | ||
|
||
env = os.environ | ||
|
||
self.SECRET: str = env.get("DISCORD_SECRET") or "" | ||
|
||
|
||
CONFIG = Config() |
Oops, something went wrong.