diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cffcb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json \ No newline at end of file diff --git a/config.json.sample b/config.json.sample new file mode 100644 index 0000000..1d7a85b --- /dev/null +++ b/config.json.sample @@ -0,0 +1,11 @@ +{ + "discord_token": "goeshere", + "matrix_token": "goeshere", + "matrix_userid": "@examplebot:example.org", + "matrix_homeserver": "https://matrix.example.org", + "rooms": { + "REMOVE_ME": "key is discord channel id as string, value is matrix room" + "123456789": "!yadayada:matrix.example.org", + "133333337": "!yadayadamore:matrix.example.org" + } +} diff --git a/main.py b/main.py index bb521b1..bfa26bc 100644 --- a/main.py +++ b/main.py @@ -2,17 +2,19 @@ import asyncio, json, os import hikari import mautrix.client +config = json.load(open("config.json", "r")) + dclient = hikari.GatewayBot( - token=os.getenv("DISCORD_TOKEN"), + token=config["discord_token"], intents=(hikari.Intents.MESSAGE_CONTENT|hikari.Intents.GUILD_MESSAGES) ) mclient = mautrix.client.ClientAPI( - os.getenv("MATRIX_USERID"), - base_url=os.getenv("MATRIX_HOMESERVER"), - token=os.getenv("MATRIX_TOKEN") + config["matrix_userid"], + base_url=config["matrix_homeserver"], + token=config["matrix_token"] ) -rooms = {1196201613132574733: "!eChKdzVweNTyHctaKQ:wired.rehab"} +rooms = config["rooms"] async def matrix_init(): for room in rooms.values(): @@ -32,7 +34,7 @@ async def on_message(event: hikari.GuildMessageCreateEvent) -> None: if not event.content: return - chanid = event.channel_id + chanid = str(event.channel_id) if chanid in rooms.keys(): print(f"<{event.message.author.global_name}> {event.content}")