From: Cory Chaplin Date: Thu, 15 May 2014 21:06:39 +0000 (+0200) Subject: MAking Wallops a specific message type X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=44f18d27ec394d3c5bb88375675e71f654d3fdad;p=KiwiIRC.git MAking Wallops a specific message type --- diff --git a/client/assets/text_themes/default.json b/client/assets/text_themes/default.json index 9f39da9..0f6f658 100644 --- a/client/assets/text_themes/default.json +++ b/client/assets/text_themes/default.json @@ -51,5 +51,6 @@ "rejoin": "%text", "set_setting": "ⓘ %text", "list_aliases": "ⓘ %text", - "ignored_pattern": "ⓘ %text" + "ignored_pattern": "ⓘ %text", + "wallops": "[WALLOPS] %text" } \ No newline at end of file diff --git a/client/src/app.js b/client/src/app.js index d65887a..595049e 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -67,7 +67,7 @@ _kiwi.global = { part: 'part', join: 'join', action: 'action', ctcp: 'ctcp', ctcpRequest: 'ctcpRequest', ctcpResponse: 'ctcpResponse', notice: 'notice', msg: 'privmsg', changeNick: 'changeNick', - channelInfo: 'channelInfo', mode: 'mode' + channelInfo: 'channelInfo', mode: 'mode', wallops: 'wallops' }; // Proxy each gateway method diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index 45106a7..563e4b5 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -295,6 +295,7 @@ _kiwi.model.Gateway = function () { this.ctcp(connection_id, false, type, target, params, callback); }; + /** * @param {String} target The target of the message (e.g. a channel or nick) * @param {String} msg The message to send @@ -441,6 +442,22 @@ _kiwi.model.Gateway = function () { this.rpcCall('irc.encoding', connection_id, args, callback); }; + /** + * Sends a Wallops message + * @param {String} target The target of the message + * @param {String} msg The message to send + * @param {Function} callback A callback function + */ + this.wallops = function (connection_id, target, msg, callback) { + console.log(target); + var args = { + target: target, + msg: msg + }; + + this.rpcCall('irc.wallops', connection_id, args, callback); + }; + return new (Backbone.Model.extend(this))(arguments); }; diff --git a/client/src/models/network.js b/client/src/models/network.js index cca4716..3247d82 100644 --- a/client/src/models/network.js +++ b/client/src/models/network.js @@ -148,6 +148,7 @@ this.gateway.on('irc_error', onIrcError, this); this.gateway.on('unknown_command', onUnknownCommand, this); this.gateway.on('channel_info', onChannelInfo, this); + this.gateway.on('wallops', onWallops, this); }, @@ -868,6 +869,24 @@ this.panels.server.addMsg('', styleText('unknown_command', {text: '[' + event.command + '] ' + display_params.join(', ', '')})); } + + + function onWallops(event) { + var panel, active_panel; + + panel = this.panels.server; + + panel.addMsg('[' + (event.nick||'') + ']', styleText('wallops', {text: event.msg}), 'wallops', {time: event.time}); + + // Show wallops to the active panel if it's channel or query window + active_panel = _kiwi.app.panels().active; + + if (active_panel !== panel) { + if (active_panel.isChannel() || active_panel.isQuery()) + _kiwi.app.panels().active.addMsg('[' + (event.nick||'') + ']', styleText('wallops', {text: event.msg}), 'wallops', {time: event.time}); + } + } + } )(); diff --git a/server/irc/commands.js b/server/irc/commands.js index 50b85c9..305e04e 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -1417,9 +1417,9 @@ handlers = { }, RPL_WALLOPS: function (command) { - this.irc_connection.emit('user ' + this.irc_connection.nick + ' notice', { + this.irc_connection.emit('user ' + this.irc_connection.nick + ' wallops', { from_server: false, - nick: 'WALLOPS: ' + command.nick, + nick: command.nick, ident: command.ident, hostname: command.hostname, target: this.irc_connection.nick, diff --git a/server/irc/user.js b/server/irc/user.js index a80f8bf..d8083bc 100755 --- a/server/irc/user.js +++ b/server/irc/user.js @@ -32,7 +32,8 @@ var IrcUser = function (irc_connection, nick) { privmsg: onPrivmsg, action: onAction, ctcp_request: onCtcpRequest, - mode: onMode + mode: onMode, + wallops: onWallops }; EventBinder.bindIrcEvents('user ' + this.nick, this.irc_events, this, irc_connection); }; @@ -316,3 +317,14 @@ function onMode(event) { time: event.time }); } + +function onWallops(event) { + this.irc_connection.clientEvent('wallops', { + nick: event.nick, + ident: event.ident, + hostname: event.hostname, + target: event.target, + msg: event.msg, + time: event.time + }); +}