diff --git a/client/components/Message.vue b/client/components/Message.vue
index 1ce71927..5f5c68ec 100644
--- a/client/components/Message.vue
+++ b/client/components/Message.vue
@@ -40,6 +40,13 @@
>
+
+
+ [
+ {{ message.from.nick }}
+ ]
+
+
-
diff --git a/client/css/style.css b/client/css/style.css
index a095d724..29b6a1a6 100644
--- a/client/css/style.css
+++ b/client/css/style.css
@@ -264,6 +264,7 @@ kbd {
#chat .whois .from::before,
#chat .nick .from::before,
#chat .action .from::before,
+#chat .plugin .from::before,
#chat .raw .from::before,
#chat .toggle-button::after,
#chat .toggle-content .more-caret::before,
@@ -426,6 +427,13 @@ kbd {
content: "\f005"; /* http://fontawesome.io/icon/star/ */
}
+#chat .plugin .from::before {
+ content: "\f1e6"; /* http://fontawesome.io/icon/plug/ */
+ transform: rotate(45deg);
+ display: inline-block;
+ padding: 1px;
+}
+
#chat .toggle-button {
display: inline-block;
transition: opacity 0.2s, transform 0.2s;
diff --git a/src/client.js b/src/client.js
index dc19685c..8d23d2fa 100644
--- a/src/client.js
+++ b/src/client.js
@@ -388,7 +388,7 @@ Client.prototype.inputLine = function(data) {
if (typeof plugin.input === "function" && (connected || plugin.allowDisconnected)) {
connected = true;
plugin.input(
- new PublicClient(client),
+ new PublicClient(client, plugin.packageInfo),
{network: target.network, chan: target.chan},
cmd,
args
diff --git a/src/models/msg.js b/src/models/msg.js
index a96edef4..f398f227 100644
--- a/src/models/msg.js
+++ b/src/models/msg.js
@@ -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;
diff --git a/src/plugins/inputs/index.js b/src/plugins/inputs/index.js
index 6ea9d8cc..7bae9e62 100644
--- a/src/plugins/inputs/index.js
+++ b/src/plugins/inputs/index.js
@@ -51,7 +51,10 @@ const getCommands = () =>
.concat(passThroughCommands)
.sort();
-const addPluginCommand = (command, func) => pluginCommands.set(command, func);
+const addPluginCommand = (packageInfo, command, func) => {
+ func.packageInfo = packageInfo;
+ pluginCommands.set(command, func);
+};
module.exports = {
addPluginCommand,
diff --git a/src/plugins/packages/index.js b/src/plugins/packages/index.js
index 55825744..5a238b85 100644
--- a/src/plugins/packages/index.js
+++ b/src/plugins/packages/index.js
@@ -27,16 +27,16 @@ module.exports = {
outdated,
};
-const packageApis = function(packageName) {
+const packageApis = function(packageInfo) {
return {
Stylesheets: {
- addFile: addStylesheet.bind(this, packageName),
+ addFile: addStylesheet.bind(this, packageInfo.packageName),
},
PublicFiles: {
- add: addFile.bind(this, packageName),
+ add: addFile.bind(this, packageInfo.packageName),
},
Commands: {
- add: inputs.addPluginCommand,
+ add: inputs.addPluginCommand.bind(this, packageInfo),
runAsUser: (command, targetId, client) =>
client.inputLine({target: targetId, text: command}),
},
@@ -98,6 +98,7 @@ function loadPackages() {
}
packageInfo = packageInfo.thelounge;
+ packageInfo.packageName = packageName;
packageMap.set(packageName, packageFile);
@@ -112,7 +113,7 @@ function loadPackages() {
}
if (packageFile.onServerStart) {
- packageFile.onServerStart(packageApis(packageName));
+ packageFile.onServerStart(packageApis(packageInfo));
}
log.info(`Package ${colors.bold(packageName)} loaded`);
diff --git a/src/plugins/packages/publicClient.js b/src/plugins/packages/publicClient.js
index c18cf668..f6507971 100644
--- a/src/plugins/packages/publicClient.js
+++ b/src/plugins/packages/publicClient.js
@@ -1,6 +1,9 @@
+const Msg = require("../../models/msg");
+
module.exports = class PublicClient {
- constructor(client) {
+ constructor(client, packageInfo) {
this.client = client;
+ this.packageInfo = packageInfo;
}
/**
@@ -37,4 +40,23 @@ 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
+ */
+ sendMessage(text, chan) {
+ chan.pushMessage(
+ this.client,
+ new Msg({
+ type: Msg.Type.PLUGIN,
+ text: text,
+ from: {
+ nick: this.packageInfo.name || this.packageInfo.packageName,
+ },
+ })
+ );
+ }
};