Commit 82659e87 authored by JC Brand's avatar JC Brand

Add extra chat room commands: /nick, /mute and /voice.

Also document the available chat room commands.
parent 78ac525e
...@@ -2021,38 +2021,47 @@ ...@@ -2021,38 +2021,47 @@
var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false], var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false],
$chat_content; $chat_content;
switch (match[1]) { switch (match[1]) {
case 'msg': case 'ban':
// TODO: Private messages converse.connection.muc.ban(this.model.get('jid'), match[2]);
break; break;
case 'clear': case 'clear':
this.clearChatRoomMessages(); this.clearChatRoomMessages();
break; break;
case 'topic': case 'deop':
converse.connection.muc.setTopic(this.model.get('jid'), match[2]); converse.connection.muc.deop(this.model.get('jid'), match[2]);
break;
case 'help':
$chat_content = this.$el.find('.chat-content');
msgs = [
'<strong>/ban</strong>: ' +__('Ban user from room'),
'<strong>/clear</strong>: ' +__('Remove messages'),
'<strong>/help</strong>: ' +__('Show this menu'),
'<strong>/kick</strong>: ' +__('Kick user from room'),
'<strong>/me</strong>: ' +__('Write in 3rd person'),
'<strong>/mute</strong>: ' +__("Remove user's ability to post messages"),
'<strong>/nick</strong>: ' +__('Change your nickname'),
'<strong>/topic</strong>: ' +__('Set room topic'),
'<strong>/voice</strong>: ' +__('Allow muted user to post messages')
];
this.showHelpMessages(msgs);
break; break;
case 'kick': case 'kick':
converse.connection.muc.kick(this.model.get('jid'), match[2]); converse.connection.muc.kick(this.model.get('jid'), match[2]);
break; break;
case 'ban': case 'mute':
converse.connection.muc.ban(this.model.get('jid'), match[2]); converse.connection.muc.mute(this.model.get('jid'), match[2]);
break;
case 'nick':
converse.connection.muc.changeNick(this.model.get('jid'), match[2]);
break; break;
case 'op': case 'op':
converse.connection.muc.op(this.model.get('jid'), match[2]); converse.connection.muc.op(this.model.get('jid'), match[2]);
break; break;
case 'deop': case 'topic':
converse.connection.muc.deop(this.model.get('jid'), match[2]); converse.connection.muc.setTopic(this.model.get('jid'), match[2]);
break; break;
case 'help': case 'voice':
$chat_content = this.$el.find('.chat-content'); converse.connection.muc.voice(this.model.get('jid'), match[2]);
msgs = [
'<strong>/help</strong>:'+__('Show this menu')+'',
'<strong>/me</strong>:'+__('Write in the third person')+'',
'<strong>/topic</strong>:'+__('Set chatroom topic')+'',
'<strong>/kick</strong>:'+__('Kick user from chatroom')+'',
'<strong>/ban</strong>:'+__('Ban user from chatroom')+'',
'<strong>/clear</strong>:'+__('Remove messages')+''
];
this.showHelpMessages(msgs);
break; break;
default: default:
this.last_msgid = converse.connection.muc.groupchat(this.model.get('jid'), body); this.last_msgid = converse.connection.muc.groupchat(this.model.get('jid'), body);
......
...@@ -393,6 +393,9 @@ ...@@ -393,6 +393,9 @@
font: inherit; font: inherit;
vertical-align: baseline; vertical-align: baseline;
} }
#conversejs strong {
font-weight: 700;
}
#conversejs, #conversejs,
#conversejs input, #conversejs input,
#conversejs textarea { #conversejs textarea {
......
...@@ -4,6 +4,8 @@ Changelog ...@@ -4,6 +4,8 @@ Changelog
0.8.1 (Unreleased) 0.8.1 (Unreleased)
------------------ ------------------
* Allow changing of nickname in a chat room via /nick command. [jcbrand]
* Allow a chat room user to be muted or unmuted with the /mute and /voice commands. [jcbrand]
* Add a chat room toolbar button for toggling the list of participants. [jcbrand] * Add a chat room toolbar button for toggling the list of participants. [jcbrand]
* Converse.js now responds to XEP-0030: Service Discovery requests. [jcbrand] * Converse.js now responds to XEP-0030: Service Discovery requests. [jcbrand]
* Bugfix. Roster groups all appear offline after page reload (with prebind). * Bugfix. Roster groups all appear offline after page reload (with prebind).
......
...@@ -340,6 +340,40 @@ Languages increase the size of the Converse.js significantly. ...@@ -340,6 +340,40 @@ Languages increase the size of the Converse.js significantly.
If you only need one, or a subset of the available languages, it's better to If you only need one, or a subset of the available languages, it's better to
make a custom build which includes only those languages that you need. make a custom build which includes only those languages that you need.
Chat Rooms
==========
Commands
--------
Here are the different commands that may be used in a chat room:
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| Event Type | When is it triggered? | Example (substitue $nickname with an actual user's nickname) |
+============+==============================================================================================+===============================================================+
| **ban** | Ban a user from the chat room. They will not be able to join again. | /ban $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **clear** | Clear the messages shown in the chat room. | /clear |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **deop** | Make a moderator a normal participant. | /deop $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **help** | Show the list of available commands. | /help |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **kick** | Kick a user out of a room. They will be able to join again. | /kick $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **me** | Speak in the 3rd person. | /me $message |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **mute** | Remove a user's ability to post messages to the room. They will still be able to observe. | /mute $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **nick** | Change your nickname. | /nick $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **op** | Make a normal participant a moderator. | /op $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **topic** | Set the topic of the chat room. | /topic ${topic text} |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
| **voice** | Allow a muted user to post messages to the room. | /voice $nickname |
+------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------+
=========== ===========
Development Development
=========== ===========
...@@ -916,7 +950,7 @@ Both message_carbons and `forward_messages`_ try to solve the same problem ...@@ -916,7 +950,7 @@ Both message_carbons and `forward_messages`_ try to solve the same problem
in two different ways. in two different ways.
Message carbons is the XEP (Jabber protocol extension) specifically drafted to Message carbons is the XEP (Jabber protocol extension) specifically drafted to
solve this problem, while `forwarded_messages`_ uses solve this problem, while `forwarded_messages`_ uses
`stanza forwarding <http://www.xmpp.org/extensions/xep-0297.html>`_ `stanza forwarding <http://www.xmpp.org/extensions/xep-0297.html>`_
expose_rid_and_sid expose_rid_and_sid
...@@ -1049,7 +1083,7 @@ Default: ``session`` ...@@ -1049,7 +1083,7 @@ Default: ``session``
Valid options: ``session``, ``local``. Valid options: ``session``, ``local``.
This option determines the type of `storage <https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage>`_ This option determines the type of `storage <https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage>`_
(``localStorage`` or ``sessionStorage``) used by converse.js to cache user data. (``localStorage`` or ``sessionStorage``) used by converse.js to cache user data.
Originally converse.js used only localStorage, however sessionStorage is from a Originally converse.js used only localStorage, however sessionStorage is from a
...@@ -1104,7 +1138,7 @@ Default: ...@@ -1104,7 +1138,7 @@ Default:
Allows you to show or hide buttons on the chat boxes' toolbars. Allows you to show or hide buttons on the chat boxes' toolbars.
* *call*: * *call*:
Provides a button with a picture of a telephone on it. Provides a button with a picture of a telephone on it.
When the call button is pressed, it will emit an event that can be used by a third-party library to initiate a call.:: When the call button is pressed, it will emit an event that can be used by a third-party library to initiate a call.::
...@@ -1113,9 +1147,9 @@ Allows you to show or hide buttons on the chat boxes' toolbars. ...@@ -1113,9 +1147,9 @@ Allows you to show or hide buttons on the chat boxes' toolbars.
console.log('Bare buddy JID is', data.model.get('jid')); console.log('Bare buddy JID is', data.model.get('jid'));
// ... Third-party library code ... // ... Third-party library code ...
}); });
* *clear*: * *clear*:
Provides a button for clearing messages from a chat box. Provides a button for clearing messages from a chat box.
* *emoticons*: * *emoticons*:
Enables rendering of emoticons and provides a toolbar button for choosing them. Enables rendering of emoticons and provides a toolbar button for choosing them.
* toggle_participants: * toggle_participants:
Shows a button for toggling (i.e. showing/hiding) the list of participants in a chat room. Shows a button for toggling (i.e. showing/hiding) the list of participants in a chat room.
......
...@@ -407,6 +407,10 @@ ...@@ -407,6 +407,10 @@
vertical-align: baseline; vertical-align: baseline;
} }
#conversejs strong {
font-weight: 700;
}
#conversejs, #conversejs,
#conversejs input, #conversejs input,
#conversejs textarea { #conversejs textarea {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment