[polari] ircParser: Use the new room methods to implement invite/kick
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] ircParser: Use the new room methods to implement invite/kick
- Date: Thu, 8 Aug 2013 13:08:12 +0000 (UTC)
commit c3cbcc0c4bb0daa9454544815ba886e9db277ca7
Author: Florian Müllner <florian muellner gmail com>
Date: Tue Jul 23 02:52:15 2013 +0200
ircParser: Use the new room methods to implement invite/kick
src/ircParser.js | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/src/ircParser.js b/src/ircParser.js
index 4c955d0..92eb669 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -14,8 +14,6 @@ const knownCommands = {
/* commands that would be nice to support: */
/*
AWAY: _("/AWAY [<message>] - sets or unsets away message"),
- INVITE: _("/INVITE <nick> [<channel>] - invites <nick> to <channel>, or the current one"),
- KICK: _("/KICK <nick> - kicks <nick> from current channel"),
LIST: _("/LIST [<channel>] - lists stats on <channel>, or all channels on the server"),
MODE: "/MODE <mode> <nick|channel> - ",
NOTICE: _("/NOTICE <nick|channel> <message> - sends notice to <nick|channel>"),
@@ -24,7 +22,9 @@ const knownCommands = {
*/
HELP: _("/HELP [<command>] - displays help for <command>, or a list of available commands"),
+ INVITE: _("/INVITE <nick> [<channel>] - invites <nick> to <channel>, or the current one"),
JOIN: _("/JOIN <channel> - joins <channel>"),
+ KICK: _("/KICK <nick> - kicks <nick> from current channel"),
ME: _("/ME <action> - sends <action> to the current channel"),
NAMES: _("/NAMES - lists users on the current channel"),
NICK: _("/NICK <nickname> - sets your nick to <nickname>"),
@@ -98,6 +98,25 @@ const IrcParser = new Lang.Class({
break;
}
+ case 'INVITE': {
+ let nick = argv.shift();
+ if (!nick) {
+ this._createFeedbackUsage(cmd);
+ break;
+ }
+ this._room.channel.connection.dup_contact_by_id_async(nick, [],
+ Lang.bind(this, function(c, res) {
+ let contact;
+ try {
+ contact = c.dup_contact_by_id_finish(res);
+ } catch(e) {
+ logError(e, 'Failed to get contact for ' + nick);
+ return;
+ }
+ this._room.add_member(contact);
+ }));
+ break;
+ }
case 'JOIN': {
let room = argv.shift();
if (!room) {
@@ -124,6 +143,25 @@ const IrcParser = new Lang.Class({
}));
break;
}
+ case 'KICK': {
+ let nick = argv.shift();
+ if (!nick) {
+ output = this._createFeedbackUsage(cmd);
+ break;
+ }
+ this._room.channel.connection.dup_contact_by_id_async(nick, [],
+ Lang.bind(this, function(c, res) {
+ let contact;
+ try {
+ contact = c.dup_contact_by_id_finish(res);
+ } catch(e) {
+ logError(e, 'Failed to get contact for ' + nick);
+ return;
+ }
+ this._room.remove_member(contact);
+ }));
+ break;
+ }
case 'ME': {
if (!argv.length) {
output = this._createFeedbackUsage(cmd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]