Skip to content

Instantly share code, notes, and snippets.

@123DMWM
Last active December 3, 2023 03:50
Show Gist options
  • Save 123DMWM/857789eef6d1f38ba032118edc0215a6 to your computer and use it in GitHub Desktop.
Save 123DMWM/857789eef6d1f38ba032118edc0215a6 to your computer and use it in GitHub Desktop.
MCGalaxy Plugin to Bridge IRC and Discord as it currently does not show one to the other.
using MCGalaxy.Modules.Relay;
using MCGalaxy.Modules.Relay.IRC;
using MCGalaxy.Modules.Relay.Discord;
namespace MCGalaxy {
public class FullBridge : Plugin {
public override string creator { get { return "123DontMessWitMe"; } }
public override string MCGalaxy_Version { get { return "1.9.3.4"; } }
public override string name { get { return "FullBridge"; } }
public override void Load(bool startup) {
OnChannelMessageEvent.Register(onMessage, Priority.Normal);
}
static void onMessage(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel) {
switch (bot.RelayName) {
case "Discord":
string fullDiscordMSG = "&I(Discord) " + user.Nick + "\x03: " + message;
if (DiscordPlugin.Config.OpChannels.CaselessContains(channel)) {
IRCPlugin.Bot.SendStaffMessage(fullDiscordMSG);
} else if (DiscordPlugin.Config.Channels.CaselessContains(channel)) {
IRCPlugin.Bot.SendPublicMessage(fullDiscordMSG);
}
break;
case "IRC":
string fullIRCMSG = "(IRC) " + user.Nick + ": " + message;
if (IRCPlugin.Bot.OpChannels.CaselessContains(channel)) {
DiscordPlugin.Bot.SendStaffMessage(fullIRCMSG);
} else if (IRCPlugin.Bot.Channels.CaselessContains(channel)) {
DiscordPlugin.Bot.SendPublicMessage(fullIRCMSG);
}
break;
default:
Logger.Log(LogType.Debug, "[FullBridge] Unknown RelayBot name, " + bot.RelayName);
break;
}
}
public override void Unload(bool shutdown) {
OnChannelMessageEvent.Unregister(onMessage);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment