diff --git a/config.json b/config.json index a589a61..014b219 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,11 @@ { - "token": "YOUR_TOKEN_HERE", - "plugin_path": "./plugins", + "token": "OTIxMDg0ODA3Mjk4MDU2MjAz.YbtxEg.b9m5CLGMDnMo7rDurswD1t7E5ec", + "plugin_path": "L:\\repos\\generational-bridge\\plugins", "authed": [ - - ] + 279611326848958465 + ], + "discord_webhook": "https://discord.com/api/webhooks/id/token", + "discord_channel": "id", + "irc_channel": "#channel", + "irc_nick": "nick" } \ No newline at end of file diff --git a/plugins/bridge.py b/plugins/bridge.py index 116b910..3e05784 100644 --- a/plugins/bridge.py +++ b/plugins/bridge.py @@ -3,12 +3,6 @@ from ircked.message import * hooks = ["READY", "MESSAGE_CREATE"] -# replace all this stuff and it should maybe probablyt just werk (tm) -_discord_webhook = "https://discord.com/api/webhooks/id/token" -_discord_channel = "id" -_irc_channel = "#channel" -_irc_nick = "genbridge" - dorfl = None disc_bot_instance = None @@ -18,26 +12,27 @@ init = False def run(event, ctx, bot): global init global dorfl + global disc_bot_instance if event == "READY": disc_bot_instance = bot if init: return init = True - dorfl = irc_bot(nick = _irc_nick) + dorfl = irc_bot(nick = disc_bot_instance.config["irc_nick"]) dorfl.connect_register("irc.rizon.net", 7000) def magic(msg, ctx): if msg.command == "PING": message.manual("", "PONG", msg.parameters).send(ctx.socket) elif msg.command == "001": - message.manual("", "JOIN", [_irc_channel]).send(ctx.socket) + message.manual("", "JOIN", [disc_bot_instance.config["irc_channel"]]).send(ctx.socket) elif msg.command == "PRIVMSG" and "\x01VERSION\x01" in msg.parameters: message.manual(":"+msg.parameters[0], "PRIVMSG", [msg.prefix[1:].split("!")[0], ":\x01dorfl bot\x01"]).send(ctx.socket) if msg.command == "PRIVMSG" and ("py-ctcp" not in msg.prefix): pm = privmsg.parse(msg) - bot.execute_webhook(_discord_webhook, pm.bod, pm.fr.split("!")[0]+" (IRC)") + disc_bot_instance.execute_webhook(disc_bot_instance.config["discord_webhook"], pm.bod, pm.fr.split("!")[0]+" (IRC)") dorfl.run(event_handler = magic) - elif event == "MESSAGE_CREATE" and init == True and ctx["channel_id"] == _discord_channel and not(bool(ctx.get("webhook_id"))): - dorfl.sendraw(privmsg.build(_irc_nick, _irc_channel, (ctx["author"]["username"] if ctx.get("member").get("nick") == None else ctx["member"]["nick"])+" (discord): "+ctx["content"]).msg) + elif event == "MESSAGE_CREATE" and init == True and ctx["channel_id"] == disc_bot_instance.config["discord_channel"] and not(bool(ctx.get("webhook_id"))): + dorfl.sendraw(privmsg.build(disc_bot_instance.config["irc_nick"], disc_bot_instance.config["irc_channel"], (ctx["author"]["username"] if ctx.get("member").get("nick") == None else ctx["member"]["nick"])+" (discord): "+ctx["content"]).msg) \ No newline at end of file