|
|
@ -3,12 +3,6 @@ from ircked.message import * |
|
|
|
|
|
|
|
|
|
|
|
hooks = ["READY", "MESSAGE_CREATE"] |
|
|
|
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 |
|
|
|
dorfl = None |
|
|
|
|
|
|
|
|
|
|
|
disc_bot_instance = None |
|
|
|
disc_bot_instance = None |
|
|
@ -18,26 +12,27 @@ init = False |
|
|
|
def run(event, ctx, bot): |
|
|
|
def run(event, ctx, bot): |
|
|
|
global init |
|
|
|
global init |
|
|
|
global dorfl |
|
|
|
global dorfl |
|
|
|
|
|
|
|
global disc_bot_instance |
|
|
|
if event == "READY": |
|
|
|
if event == "READY": |
|
|
|
disc_bot_instance = bot |
|
|
|
disc_bot_instance = bot |
|
|
|
if init: |
|
|
|
if init: |
|
|
|
return |
|
|
|
return |
|
|
|
init = True |
|
|
|
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) |
|
|
|
dorfl.connect_register("irc.rizon.net", 7000) |
|
|
|
|
|
|
|
|
|
|
|
def magic(msg, ctx): |
|
|
|
def magic(msg, ctx): |
|
|
|
if msg.command == "PING": |
|
|
|
if msg.command == "PING": |
|
|
|
message.manual("", "PONG", msg.parameters).send(ctx.socket) |
|
|
|
message.manual("", "PONG", msg.parameters).send(ctx.socket) |
|
|
|
elif msg.command == "001": |
|
|
|
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: |
|
|
|
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) |
|
|
|
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): |
|
|
|
if msg.command == "PRIVMSG" and ("py-ctcp" not in msg.prefix): |
|
|
|
pm = privmsg.parse(msg) |
|
|
|
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) |
|
|
|
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"))): |
|
|
|
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(_irc_nick, _irc_channel, (ctx["author"]["username"] if ctx.get("member").get("nick") == None else ctx["member"]["nick"])+" (discord): "+ctx["content"]).msg) |
|
|
|
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) |
|
|
|
|
|
|
|
|