Fix: Fixed a bug where rellaymsg from a user with a nick with special chars or a special font would not send over to the IRC side.
This commit is contained in:
33
bot.js
33
bot.js
@@ -39,6 +39,11 @@ function logForward(...args) {
|
|||||||
if (LOG_FORWARD) console.log(...args);
|
if (LOG_FORWARD) console.log(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Utility to check ASCII
|
||||||
|
function isASCII(str) {
|
||||||
|
return /^[\x00-\x7F]*$/.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
// Create IRC client for a bridge
|
// Create IRC client for a bridge
|
||||||
function createIRCClient(bridge) {
|
function createIRCClient(bridge) {
|
||||||
const ircConfig = bridge.irc;
|
const ircConfig = bridge.irc;
|
||||||
@@ -206,22 +211,18 @@ discordClient.on("messageCreate", async (message) => {
|
|||||||
|
|
||||||
logForward(`Forwarding Discord → IRC [${info.channel}]: ${privmsgMessage}`);
|
logForward(`Forwarding Discord → IRC [${info.channel}]: ${privmsgMessage}`);
|
||||||
|
|
||||||
// --- RELAYMSG logic ---
|
// RELAYMSG logic with proper fallback for non-ASCII
|
||||||
if (info.useRelayMsg) {
|
if (info.useRelayMsg && ircClient.state.hasOp && isASCII(nickname)) {
|
||||||
if (ircClient.state.hasOp) {
|
const relayNick = `${nickname}/dc`;
|
||||||
const relayNick = `${nickname}/dc`;
|
ircClient.raw(`RELAYMSG ${info.channel} ${relayNick} :${baseMessage}`);
|
||||||
ircClient.raw(`RELAYMSG ${info.channel} ${relayNick} :${baseMessage}`);
|
|
||||||
} else {
|
|
||||||
if (!ircClient.state.warnedRelayMsg) {
|
|
||||||
ircClient.say(
|
|
||||||
info.channel,
|
|
||||||
`[Bridge] Missing +o, falling back to PRIVMSG (RELAYMSG disabled)`
|
|
||||||
);
|
|
||||||
ircClient.state.warnedRelayMsg = true;
|
|
||||||
}
|
|
||||||
ircClient.say(info.channel, privmsgMessage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
if (info.useRelayMsg && !ircClient.state.hasOp && !ircClient.state.warnedRelayMsg) {
|
||||||
|
ircClient.say(
|
||||||
|
info.channel,
|
||||||
|
`[Bridge] Missing +o, falling back to PRIVMSG (RELAYMSG disabled)`
|
||||||
|
);
|
||||||
|
ircClient.state.warnedRelayMsg = true;
|
||||||
|
}
|
||||||
ircClient.say(info.channel, privmsgMessage);
|
ircClient.say(info.channel, privmsgMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,7 +257,7 @@ discordClient.on("messageReactionAdd", async (reaction, user) => {
|
|||||||
|
|
||||||
logForward(`Reaction → IRC [${info.channel}]: ${reactionMessage}`);
|
logForward(`Reaction → IRC [${info.channel}]: ${reactionMessage}`);
|
||||||
|
|
||||||
if (info.useRelayMsg && ircClient.state.hasOp) {
|
if (info.useRelayMsg && ircClient.state.hasOp && isASCII(nickname)) {
|
||||||
const relayNick = `${nickname}/dc`;
|
const relayNick = `${nickname}/dc`;
|
||||||
ircClient.raw(
|
ircClient.raw(
|
||||||
`RELAYMSG ${info.channel} ${relayNick} :${reactionMessage}`
|
`RELAYMSG ${info.channel} ${relayNick} :${reactionMessage}`
|
||||||
|
|||||||
Reference in New Issue
Block a user