mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-19 16:22:10 +00:00
Conanjurer generation
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Punkt wejścia bota mostu Discord <-> Conan Exiles."""
|
||||
from __future__ import annotations
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from bot.core.config import Config
|
||||
from bot.core.rcon import RconClient
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||
)
|
||||
log = logging.getLogger("main")
|
||||
|
||||
COGS = ["bot.cogs.from_conan", "bot.cogs.to_conan"]
|
||||
|
||||
|
||||
class BridgeBot(commands.Bot):
|
||||
def __init__(self, cfg: Config):
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True # potrzebne do komend prefiksowych
|
||||
super().__init__(command_prefix="!", intents=intents)
|
||||
self.cfg = cfg
|
||||
self.rcon = RconClient(cfg.rcon_host, cfg.rcon_port, cfg.rcon_password)
|
||||
|
||||
async def setup_hook(self):
|
||||
for c in COGS:
|
||||
await self.load_extension(c)
|
||||
log.info("Załadowano cog: %s", c)
|
||||
|
||||
async def close(self):
|
||||
await self.rcon.close()
|
||||
await super().close()
|
||||
|
||||
async def on_ready(self):
|
||||
log.info("Zalogowano jako %s (id=%s)", self.user, self.user.id)
|
||||
|
||||
|
||||
def main():
|
||||
cfg = Config.load()
|
||||
bot = BridgeBot(cfg)
|
||||
bot.run(cfg.token, log_handler=None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user