diff options
author | latex <latex@disroot.org> | 2023-03-27 00:45:26 +0200 |
---|---|---|
committer | latex <latex@disroot.org> | 2023-03-27 00:45:26 +0200 |
commit | 8c43b5372b0928b0bc1d0eec93898f4927fbc1e3 (patch) | |
tree | d3780c3d2c89c09f1d53d7d7d8e16e1c215b0358 /src | |
download | mumblecord-8c43b5372b0928b0bc1d0eec93898f4927fbc1e3.tar.gz |
welcome to mumblecord
Diffstat (limited to 'src')
-rw-r--r-- | src/main.py | 22 | ||||
-rw-r--r-- | src/mumblecord.py | 35 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..69f6a57 --- /dev/null +++ b/src/main.py @@ -0,0 +1,22 @@ +import asyncio +import argparse +import configparser +import mumblecord + +parser = argparse.ArgumentParser( + prog="mumblecord", + description="Bridge Mumble and Discord") +parser.add_argument("-c", "--config", + help="the path to the configuration file", + action="store", default="mumblecord.conf") +args = parser.parse_args() + +conf = configparser.ConfigParser() +conf.read(args.config) +conf_mumble = conf["mumble"] +conf_discord = conf["discord"] + +bot = mumblecord.Mumblecord(conf_mumble, conf_discord) + +while True: + pass diff --git a/src/mumblecord.py b/src/mumblecord.py new file mode 100644 index 0000000..914265f --- /dev/null +++ b/src/mumblecord.py @@ -0,0 +1,35 @@ +import asyncio +import pymumble_py3 +import discord + +class Discord(discord.Client): + def __init__(self, mumblecord): + self.mumblecord = mumblecord + super().__init__() + + async def on_ready(self): + print(f"Discord: logged in as {self.user}") + self.mumblecord.mumble.users.myself.comment(f"{self.user}") + +class Mumblecord: + def __init__(self, conf_mumble, conf_discord): + self.mumble_host = conf_mumble["host"] + self.mumble_port = conf_mumble.getint("port", 64738) + self.mumble_user = conf_mumble.get("user", "mumblecord") + self.mumble_password = conf_mumble.get("password", "") + self.mumble_cert = conf_mumble.get("cert", None) + self.mumble_key = conf_mumble.get("key", None) + + self.discord_token = conf_discord["token"] + + self.mumble = pymumble_py3.Mumble(self.mumble_host, self.mumble_user, + password=self.mumble_password, + certfile=self.mumble_cert, keyfile=self.mumble_key, stereo=True) + self.mumble.start() + self.mumble.is_ready() + + asyncio.run(self._init_discord()) + + async def _init_discord(self): + self.discord = Discord(self) + await self.discord.start(self.discord_token) |