Преглед на файлове

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

Also document the available chat room commands.
JC Brand преди 10 години
родител
ревизия
82659e87d7
променени са 5 файла, в които са добавени 76 реда и са изтрити 24 реда
  1. 28 19
      converse.js
  2. 3 0
      css/converse.css
  3. 2 0
      docs/CHANGES.rst
  4. 39 5
      docs/source/index.rst
  5. 4 0
      less/converse.less

+ 28 - 19
converse.js

@@ -2021,38 +2021,47 @@
                 var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false],
                     $chat_content;
                 switch (match[1]) {
-                    case 'msg':
-                        // TODO: Private messages
+                    case 'ban':
+                        converse.connection.muc.ban(this.model.get('jid'), match[2]);
                         break;
                     case 'clear':
                         this.clearChatRoomMessages();
                         break;
-                    case 'topic':
-                        converse.connection.muc.setTopic(this.model.get('jid'), match[2]);
+                    case 'deop':
+                        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;
                     case 'kick':
                         converse.connection.muc.kick(this.model.get('jid'), match[2]);
                         break;
-                    case 'ban':
-                        converse.connection.muc.ban(this.model.get('jid'), match[2]);
+                    case 'mute':
+                        converse.connection.muc.mute(this.model.get('jid'), match[2]);
+                        break;
+                    case 'nick':
+                        converse.connection.muc.changeNick(this.model.get('jid'), match[2]);
                         break;
                     case 'op':
                         converse.connection.muc.op(this.model.get('jid'), match[2]);
                         break;
-                    case 'deop':
-                        converse.connection.muc.deop(this.model.get('jid'), match[2]);
+                    case 'topic':
+                        converse.connection.muc.setTopic(this.model.get('jid'), match[2]);
                         break;
-                    case 'help':
-                        $chat_content = this.$el.find('.chat-content');
-                        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);
+                    case 'voice':
+                        converse.connection.muc.voice(this.model.get('jid'), match[2]);
                         break;
                     default:
                         this.last_msgid = converse.connection.muc.groupchat(this.model.get('jid'), body);

+ 3 - 0
css/converse.css

@@ -393,6 +393,9 @@
   font: inherit;
   vertical-align: baseline;
 }
+#conversejs strong {
+  font-weight: 700;
+}
 #conversejs,
 #conversejs input,
 #conversejs textarea {

+ 2 - 0
docs/CHANGES.rst

@@ -4,6 +4,8 @@ Changelog
 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]
 * Converse.js now responds to XEP-0030: Service Discovery requests. [jcbrand]
 * Bugfix. Roster groups all appear offline after page reload (with prebind).

+ 39 - 5
docs/source/index.rst

@@ -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
 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
 ===========
@@ -916,7 +950,7 @@ Both message_carbons and `forward_messages`_ try to solve the same problem
 in two different ways.
 
 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>`_
 
 expose_rid_and_sid
@@ -1049,7 +1083,7 @@ Default: ``session``
 
 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.
 
 Originally converse.js used only localStorage, however sessionStorage is from a
@@ -1104,7 +1138,7 @@ Default:
 
 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.
     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.
             console.log('Bare buddy JID is', data.model.get('jid'));
             // ... Third-party library code ...
         });
-* *clear*: 
+* *clear*:
     Provides a button for clearing messages from a chat box.
-* *emoticons*: 
+* *emoticons*:
     Enables rendering of emoticons and provides a toolbar button for choosing them.
 * toggle_participants:
     Shows a button for toggling (i.e. showing/hiding) the list of participants in a chat room.

+ 4 - 0
less/converse.less

@@ -407,6 +407,10 @@
 	vertical-align: baseline;
 }
 
+#conversejs strong {
+    font-weight: 700;
+}
+
 #conversejs,
 #conversejs input,
 #conversejs textarea {