Add message type for plugins

This commit is contained in:
MiniDigger 2019-10-22 18:44:05 +02:00
parent d237647f8a
commit 19d69ba4c3
3 changed files with 32 additions and 1 deletions

View file

@ -40,6 +40,13 @@
<span class="only-copy">&gt; </span>
</template>
</span>
<span v-else-if="message.type === 'plugin'" class="from">
<template v-if="message.from && message.from.nick">
<span class="only-copy">[</span>
*{{ message.from.nick }}
<span class="only-copy">] </span>
</template>
</span>
<span v-else class="from">
<template v-if="message.from && message.from.nick">
<span class="only-copy">-</span>

View file

@ -48,7 +48,8 @@ class Msg {
this.type !== Msg.Type.TOPIC_SET_BY &&
this.type !== Msg.Type.MODE_CHANNEL &&
this.type !== Msg.Type.RAW &&
this.type !== Msg.Type.WHOIS
this.type !== Msg.Type.WHOIS &&
this.type !== Msg.Type.PLUGIN
);
}
}
@ -77,6 +78,7 @@ Msg.Type = {
TOPIC_SET_BY: "topic_set_by",
WHOIS: "whois",
RAW: "raw",
PLUGIN: "plugin",
};
module.exports = Msg;

View file

@ -1,3 +1,5 @@
const Msg = require("../../models/msg");
module.exports = class PublicClient {
constructor(client) {
this.client = client;
@ -37,4 +39,24 @@ module.exports = class PublicClient {
getChannel(chanId) {
return this.client.find(chanId);
}
/**
* Sends a message to this client, displayed in the given channel.
*
* @param {String} text the message to send
* @param {Chan} chan the channel to send the message to
* @param {String} identifier the identifier/name of the packages that is sending this message
*/
sendMessage(text, chan, identifier) {
chan.pushMessage(
this.client,
new Msg({
type: Msg.Type.PLUGIN,
text: text,
from: {
nick: identifier,
},
})
);
}
};