Pass PREFIX and CHANTYPES to parser
This commit is contained in:
parent
cebfa6ac84
commit
f2cbd1efed
@ -28,6 +28,7 @@
|
||||
:title="channel.topic"
|
||||
class="topic"><ParsedMessage
|
||||
v-if="channel.topic"
|
||||
:network="network"
|
||||
:text="channel.topic"/></span>
|
||||
<button
|
||||
class="menu"
|
||||
@ -50,6 +51,7 @@
|
||||
<div class="msg">
|
||||
<component
|
||||
:is="specialComponent"
|
||||
:network="network"
|
||||
:channel="channel"/>
|
||||
</div>
|
||||
</div>
|
||||
@ -59,6 +61,7 @@
|
||||
v-else
|
||||
class="chat-content">
|
||||
<MessageList
|
||||
:network="network"
|
||||
:channel="channel"
|
||||
:settings="settings"/>
|
||||
<ChatUserList
|
||||
|
@ -19,12 +19,15 @@
|
||||
<span class="from"/>
|
||||
<component
|
||||
:is="messageComponent"
|
||||
:network="network"
|
||||
:message="message"/>
|
||||
</template>
|
||||
<template v-else-if="message.type === 'action'">
|
||||
<span class="from"/>
|
||||
<span class="content">
|
||||
<span class="text"><Username :user="message.from"/> <ParsedMessage :message="message"/></span>
|
||||
<span class="text"><Username :user="message.from"/> <ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/></span>
|
||||
<LinkPreview
|
||||
v-for="preview in message.previews"
|
||||
:keep-scroll-position="keepScrollPosition"
|
||||
@ -39,7 +42,9 @@
|
||||
</template>
|
||||
</span>
|
||||
<span class="content">
|
||||
<span class="text"><ParsedMessage :message="message"/></span>
|
||||
<span class="text"><ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/></span>
|
||||
<LinkPreview
|
||||
v-for="preview in message.previews"
|
||||
:keep-scroll-position="keepScrollPosition"
|
||||
@ -65,6 +70,7 @@ export default {
|
||||
components: MessageTypes,
|
||||
props: {
|
||||
message: Object,
|
||||
network: Object,
|
||||
keepScrollPosition: Function,
|
||||
},
|
||||
computed: {
|
||||
|
@ -11,6 +11,7 @@
|
||||
</div>
|
||||
<Message
|
||||
v-for="message in messages"
|
||||
:network="network"
|
||||
:message="message"
|
||||
:key="message.id"/>
|
||||
</div>
|
||||
@ -26,6 +27,7 @@ export default {
|
||||
Message,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
messages: Array,
|
||||
},
|
||||
data() {
|
||||
|
@ -46,9 +46,11 @@
|
||||
<MessageCondensed
|
||||
v-if="message.type === 'condensed'"
|
||||
:key="message.id"
|
||||
:network="network"
|
||||
:messages="message.messages"/>
|
||||
<Message
|
||||
v-else
|
||||
:network="network"
|
||||
:message="message"
|
||||
:key="message.id"
|
||||
:keep-scroll-position="keepScrollPosition"
|
||||
@ -89,6 +91,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
settings: Object,
|
||||
network: Object,
|
||||
channel: Object,
|
||||
},
|
||||
computed: {
|
||||
|
@ -2,11 +2,14 @@
|
||||
<span class="content">
|
||||
<ParsedMessage
|
||||
v-if="message.self"
|
||||
:network="network"
|
||||
:message="message"/>
|
||||
<template v-else>
|
||||
<Username :user="message.from"/>
|
||||
is away
|
||||
<i class="away-message">(<ParsedMessage :message="message"/>)</i>
|
||||
<i class="away-message">(<ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/>)</i>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
@ -22,6 +25,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
<span class="content">
|
||||
<ParsedMessage
|
||||
v-if="message.self"
|
||||
:network="network"
|
||||
:message="message"/>
|
||||
<template v-else>
|
||||
<Username :user="message.from"/>
|
||||
@ -21,6 +22,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -6,7 +6,9 @@
|
||||
<Username
|
||||
v-else
|
||||
:user="message.target"/>
|
||||
to <ParsedMessage :text="message.channel"/>
|
||||
to <ParsedMessage
|
||||
:network="network"
|
||||
:text="message.channel"/>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -21,6 +23,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -5,7 +5,9 @@
|
||||
<Username :user="message.target"/>
|
||||
<i
|
||||
v-if="message.text"
|
||||
class="part-reason">(<ParsedMessage :message="message"/>)</i>
|
||||
class="part-reason">(<ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/>)</i>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -20,6 +22,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<span class="content">
|
||||
<span class="text"><ParsedMessage :text="cleanText"/></span>
|
||||
<span class="text"><ParsedMessage
|
||||
:network="network"
|
||||
:text="cleanText"/></span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -13,6 +15,7 @@ export default {
|
||||
ParsedMessage,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
computed: {
|
||||
|
@ -5,7 +5,9 @@
|
||||
has left the channel
|
||||
<i
|
||||
v-if="message.text"
|
||||
class="part-reason">(<ParsedMessage :message="message"/>)</i>
|
||||
class="part-reason">(<ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/>)</i>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -20,6 +22,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -5,7 +5,9 @@
|
||||
has quit
|
||||
<i
|
||||
v-if="message.text"
|
||||
class="quit-reason">(<ParsedMessage :message="message"/>)</i>
|
||||
class="quit-reason">(<ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/>)</i>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -20,6 +22,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -9,7 +9,9 @@
|
||||
</template>
|
||||
<span
|
||||
v-if="message.text"
|
||||
class="new-topic"><ParsedMessage :message="message"/></span>
|
||||
class="new-topic"><ParsedMessage
|
||||
:network="network"
|
||||
:message="message"/></span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@ -24,6 +26,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -27,7 +27,9 @@
|
||||
|
||||
<template v-if="message.whois.real_name">
|
||||
<dt>Real name:</dt>
|
||||
<dd><ParsedMessage :text="message.whois.real_name"/></dd>
|
||||
<dd><ParsedMessage
|
||||
:network="network"
|
||||
:text="message.whois.real_name"/></dd>
|
||||
</template>
|
||||
|
||||
<template v-if="message.whois.registered_nick">
|
||||
@ -37,7 +39,9 @@
|
||||
|
||||
<template v-if="message.whois.channels">
|
||||
<dt>Channels:</dt>
|
||||
<dd><ParsedMessage :text="message.whois.channels"/></dd>
|
||||
<dd><ParsedMessage
|
||||
:network="network"
|
||||
:text="message.whois.channels"/></dd>
|
||||
</template>
|
||||
|
||||
<template v-if="message.whois.modes">
|
||||
@ -67,7 +71,9 @@
|
||||
|
||||
<template v-if="message.whois.away">
|
||||
<dt>Away:</dt>
|
||||
<dd><ParsedMessage :text="message.whois.away"/></dd>
|
||||
<dd><ParsedMessage
|
||||
:network="network"
|
||||
:text="message.whois.away"/></dd>
|
||||
</template>
|
||||
|
||||
<template v-if="message.whois.secure">
|
||||
@ -104,6 +110,7 @@ export default {
|
||||
Username,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
message: Object,
|
||||
},
|
||||
};
|
||||
|
@ -7,13 +7,15 @@ export default {
|
||||
props: {
|
||||
text: String,
|
||||
message: Object,
|
||||
network: Object,
|
||||
},
|
||||
render(createElement, context) {
|
||||
if (typeof context.props.text !== "undefined") {
|
||||
return parse(createElement, context.props.text);
|
||||
}
|
||||
|
||||
return parse(createElement, context.props.message.text, context.props.message);
|
||||
return parse(
|
||||
createElement,
|
||||
typeof context.props.text !== "undefined" ? context.props.text : context.props.message.text,
|
||||
context.props.message,
|
||||
context.props.network
|
||||
);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -23,6 +23,7 @@
|
||||
export default {
|
||||
name: "ListBans",
|
||||
props: {
|
||||
network: Object,
|
||||
channel: Object,
|
||||
},
|
||||
};
|
||||
|
@ -14,9 +14,13 @@
|
||||
<tr
|
||||
v-for="chan in channel.data"
|
||||
:key="chan.channel">
|
||||
<td class="channel"><ParsedMessage :text="chan.channel"/></td>
|
||||
<td class="channel"><ParsedMessage
|
||||
:network="network"
|
||||
:text="chan.channel"/></td>
|
||||
<td class="users">{{ chan.num_users }}</td>
|
||||
<td class="topic"><ParsedMessage :text="chan.topic"/></td>
|
||||
<td class="topic"><ParsedMessage
|
||||
:network="network"
|
||||
:text="chan.topic"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -31,6 +35,7 @@ export default {
|
||||
ParsedMessage,
|
||||
},
|
||||
props: {
|
||||
network: Object,
|
||||
channel: Object,
|
||||
},
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
export default {
|
||||
name: "ListIgnored",
|
||||
props: {
|
||||
network: Object,
|
||||
channel: Object,
|
||||
},
|
||||
};
|
||||
|
@ -57,7 +57,7 @@ function createFragment(fragment, createElement) {
|
||||
|
||||
// Transform an IRC message potentially filled with styling control codes, URLs,
|
||||
// nicknames, and channels into a string of HTML elements to display on the client.
|
||||
module.exports = function parse(createElement, text, message = null) {
|
||||
module.exports = function parse(createElement, text, message = undefined, network = undefined) {
|
||||
// Extract the styling information and get the plain text version from it
|
||||
const styleFragments = parseStyle(text);
|
||||
const cleanText = styleFragments.map((fragment) => fragment.text).join("");
|
||||
@ -65,8 +65,8 @@ module.exports = function parse(createElement, text, message = null) {
|
||||
// On the plain text, find channels and URLs, returned as "parts". Parts are
|
||||
// arrays of objects containing start and end markers, as well as metadata
|
||||
// depending on what was found (channel or link).
|
||||
const channelPrefixes = ["#", "&"]; // TODO Channel prefixes should be RPL_ISUPPORT.CHANTYPES
|
||||
const userModes = ["!", "@", "%", "+"]; // TODO User modes should be RPL_ISUPPORT.PREFIX
|
||||
const channelPrefixes = network ? network.serverOptions.CHANTYPES : ["#", "&"];
|
||||
const userModes = network ? network.serverOptions.PREFIX : ["!", "@", "%", "+"];
|
||||
const channelParts = findChannels(cleanText, channelPrefixes, userModes);
|
||||
const linkParts = findLinks(cleanText);
|
||||
const emojiParts = findEmoji(cleanText);
|
||||
|
@ -27,7 +27,7 @@ socket.on("network", function(data) {
|
||||
.prop("disabled", false);
|
||||
});
|
||||
|
||||
socket.on("network_changed", function(data) {
|
||||
socket.on("network:options", function(data) {
|
||||
vueApp.networks.find((n) => n.uuid === data.network).serverOptions = data.serverOptions;
|
||||
});
|
||||
|
||||
|
@ -40,6 +40,7 @@ function Network(attr) {
|
||||
hostname: null,
|
||||
irc: null,
|
||||
serverOptions: {
|
||||
CHANTYPES: [],
|
||||
PREFIX: [],
|
||||
NETWORK: "",
|
||||
},
|
||||
|
@ -142,20 +142,17 @@ module.exports = function(irc, network) {
|
||||
});
|
||||
|
||||
irc.on("server options", function(data) {
|
||||
if (network.serverOptions.PREFIX === data.options.PREFIX && network.serverOptions.NETWORK === data.options.NETWORK) {
|
||||
return;
|
||||
}
|
||||
|
||||
network.prefixLookup = {};
|
||||
|
||||
data.options.PREFIX.forEach((mode) => {
|
||||
network.prefixLookup[mode.mode] = mode.symbol;
|
||||
});
|
||||
|
||||
network.serverOptions.PREFIX = data.options.PREFIX;
|
||||
network.serverOptions.CHANTYPES = data.options.CHANTYPES;
|
||||
network.serverOptions.PREFIX = data.options.PREFIX.map((p) => p.symbol);
|
||||
network.serverOptions.NETWORK = data.options.NETWORK;
|
||||
|
||||
client.emit("network_changed", {
|
||||
client.emit("network:options", {
|
||||
network: network.uuid,
|
||||
serverOptions: network.serverOptions,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user