从房间配置MUC中删除一些选项 [英] Remove some options from room config MUC

查看:65
本文介绍了从房间配置MUC中删除一些选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当所有者加入并且房间和打开房间的配置面板出现很少的配置选项时。

When owner join and the room and open room config panel when few config options appears.

我想从配置面板中删除一些选项,例如

I want to remove some options from config panel like


  1. 最大用户数>最大限制为200,但我想将最大限制设置为30,并且字段不可编辑。 (没有人可以更改30个限制)

  1. Maximum number of users > max limit is 200 but i want to set max limit to 30 and field is uneditable. (No one can change 30 limit)


  1. 将实际Jid按下-(默认为主持人)
    i希望将默认值设置为所有人和字段隐藏。

  1. Pressence real Jids to - (Default is Moderator) i want to set default value is Everyone and field hidden.

广播存在状态的角色
(全部选中默认值)。只想隐藏此字段。没什么改变。

Roles of which presence is broadcast (Default is selected all). just want to hide this field. Nothing change.

让房间受到监控(只是想隐藏此字段。未选中。)

Make room moderated (just want to hide this field. Unchecked.)

默认用户为参与者(只想隐藏此字段。默认情况下选中)

Default users as participant (just want to hide this field. Checked by default)

允许访问者通过状态广播发送状态文本(只想隐藏该字段。未选中)

Allow visitors to send status text in presence broadcast (Just want to hide this field. Unchecked)

允许访问者更改昵称(只想隐藏此字段。未选中)

Allow visitor to change nickname (just want to hide this field. Unchecked)

允许访问者发送语音请求(只想取消选中并隐藏此字段)

Allow visitor to send voice request (Just want to Uncheck and hide this field)

允许订阅(只想取消选中并隐藏)此字段)

Allow Subscribtion (Just want to Uncheck and hide this field)


我知道所有这些修改都将在.erl文件,我尝试执行但没有任何反应。谁能知道该怎么做。

I know these all modification will done in .erl file and i try to do but nothing happens. Can anyone know how to do this.

请帮助。

推荐答案

作为服务器管理员,您可以使用以下mod_muc选项在ejabberd.yml中设置默认房间值:default_room_options,请参见 https://docs.ejabberd.im/admin/configuration/#mod-muc

As a server admin, you can set default room values in ejabberd.yml with this mod_muc option: default_room_options, see https://docs.ejabberd.im/admin/configuration/#mod-muc

然后您必须修改mod_muc_room.erl隐藏该字段,如果聪明的房间所有者手动添加这些选项,也不要使用这些选项。稍后,您编译该文件(或所有ejabberd),并安装修改后的mod_muc_room.beam,覆盖旧文件,最后重新启动ejabberd。如果看不到更改,也许您将梁文件复制到了另一个位置(也许您安装了两个ejabberd,一个正在运行,而另一个又旧又使您感到困惑?)。

Then you have to modify mod_muc_room.erl to hide the field, and also to not use the options if a clever room owner adds them manually. Later you compile this file (or all ejabberd), and install the modified mod_muc_room.beam, overwritting the old one, and finally restart ejabberd. If you don't see the changes, maybe you copied the beam file to another place (maybe you have two ejabberd installed, one that is running and other that is old and is confusing you?).

我认为此更改包括您想要的所有选项,但是最好您进行验证,也许我忘记了一些。我在ejabberd 18.09中尝试了此更改,它在房间配置公式中隐藏了几个选项:

I think this change includes all the options you wanted, but better you verify, maybe I forgot some. I tried this change in ejabberd 18.09, and it hides several options in the room config formulary:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..a6fc0e73f 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -58,7 +58,7 @@
 -include("mod_muc_room.hrl").

 -define(MAX_USERS_DEFAULT_LIST,
-   [5, 10, 20, 30, 50, 100, 200, 500, 1000, 2000, 5000]).
+   [30]).

 -define(DEFAULT_MAX_USERS_PRESENCE,1000).

@@ -3363,23 +3363,23 @@ get_config(Lang, StateData, From) ->
                     MaxUsersRoom
                     | ?MAX_USERS_DEFAULT_LIST]),
               N =< ServiceMaxUsers]},
-    {whois, if Config#config.anonymous -> moderators;
-           true -> anyone
-        end},
-    {presencebroadcast, Config#config.presence_broadcast},
+    %{whois, if Config#config.anonymous -> moderators;
+   %       true -> anyone
+   %    end},
+    %{presencebroadcast, Config#config.presence_broadcast},
     {membersonly, Config#config.members_only},
-    {moderatedroom, Config#config.moderated},
-    {members_by_default, Config#config.members_by_default},
+    %{moderatedroom, Config#config.moderated},
+    %{members_by_default, Config#config.members_by_default},
     {changesubject, Config#config.allow_change_subj},
     {allow_private_messages, Config#config.allow_private_messages},
     {allow_private_messages_from_visitors,
      Config#config.allow_private_messages_from_visitors},
     {allow_query_users, Config#config.allow_query_users},
     {allowinvites, Config#config.allow_user_invites},
-    {allow_visitor_status, Config#config.allow_visitor_status},
-    {allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
-    {allow_voice_requests, Config#config.allow_voice_requests},
-    {allow_subscription, Config#config.allow_subscription},
+    %{allow_visitor_status, Config#config.allow_visitor_status},
+    %{allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
+    %{allow_voice_requests, Config#config.allow_voice_requests},
+    %{allow_subscription, Config#config.allow_subscription},
     {voice_request_min_interval, Config#config.voice_request_min_interval},
     {pubsub, Config#config.pubsub}]
    ++
@@ -3440,27 +3440,27 @@ set_config(Opts, Config, ServerHost, Lang) ->
          C#config{allow_private_messages = V};
     ({allow_private_messages_from_visitors, V}, C) ->
          C#config{allow_private_messages_from_visitors = V};
-    ({allow_visitor_status, V}, C) -> C#config{allow_visitor_status = V};
-    ({allow_visitor_nickchange, V}, C) ->
-         C#config{allow_visitor_nickchange = V};
+    %({allow_visitor_status, V}, C) -> C#config{allow_visitor_status = V};
+    %({allow_visitor_nickchange, V}, C) ->
+         %C#config{allow_visitor_nickchange = V};
     ({publicroom, V}, C) -> C#config{public = V};
     ({public_list, V}, C) -> C#config{public_list = V};
     ({persistentroom, V}, C) -> C#config{persistent = V};
-    ({moderatedroom, V}, C) -> C#config{moderated = V};
-    ({members_by_default, V}, C) -> C#config{members_by_default = V};
+    %({moderatedroom, V}, C) -> C#config{moderated = V};
+    %({members_by_default, V}, C) -> C#config{members_by_default = V};
     ({membersonly, V}, C) -> C#config{members_only = V};
     ({captcha_protected, V}, C) -> C#config{captcha_protected = V};
     ({allowinvites, V}, C) -> C#config{allow_user_invites = V};
-    ({allow_subscription, V}, C) -> C#config{allow_subscription = V};
+    %({allow_subscription, V}, C) -> C#config{allow_subscription = V};
     ({passwordprotectedroom, V}, C) -> C#config{password_protected = V};
     ({roomsecret, V}, C) -> C#config{password = V};
     ({anonymous, V}, C) -> C#config{anonymous = V};
     ({presencebroadcast, V}, C) -> C#config{presence_broadcast = V};
-    ({allow_voice_requests, V}, C) -> C#config{allow_voice_requests = V};
+    %({allow_voice_requests, V}, C) -> C#config{allow_voice_requests = V};
     ({voice_request_min_interval, V}, C) ->
          C#config{voice_request_min_interval = V};
-    ({whois, moderators}, C) -> C#config{anonymous = true};
-    ({whois, anyone}, C) -> C#config{anonymous = false};
+    %({whois, moderators}, C) -> C#config{anonymous = true};
+    %({whois, anyone}, C) -> C#config{anonymous = false};
     ({maxusers, V}, C) -> C#config{max_users = V};
     ({enablelogging, V}, C) -> C#config{logging = V};
     ({pubsub, V}, C) -> C#config{pubsub = V};

有一个选项禁止访问者更改昵称。如果您希望此选项也禁止参与者,请应用此更改:

There's an option that disallows visitors to change nickname. If you want this option to also disallow participants, apply this change:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..16ce21ba1 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -1031,7 +1031,7 @@ do_process_presence(Nick, #presence{from = From, type = available, lang = Lang}
                           StateData#state.host,
                           From, Nick),
              {(StateData#state.config)#config.allow_visitor_nickchange,
-              is_visitor(From, StateData)}} of
+              is_visitor_or_participant(From, StateData)}} of
            {_, _, {false, true}} ->
                Packet1 = Packet#presence{sub_els = [#muc{}]},
                ErrText = <<"Visitors are not allowed to change their "
@@ -1501,6 +1501,11 @@ get_default_role(Affiliation, StateData) ->
 is_visitor(Jid, StateData) ->
     get_role(Jid, StateData) =:= visitor.

+is_visitor_or_participant(Jid, StateData) ->
+    (get_role(Jid, StateData) =:= visitor)
+    or
+    (get_role(Jid, StateData) =:= participant).
+
 -spec is_moderator(jid(), state()) -> boolean().
 is_moderator(Jid, StateData) ->
     get_role(Jid, StateData) =:= moderator.

另一方面,如果您要禁止所有角色更改昵称,则更改较小:

On the other hand, if you want to disallow all roles to change the nick, the change is smaller:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..2ef75e6ed 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -1032,7 +1032,7 @@ do_process_presence(Nick, #presence{from = From, type = available, lang = Lang}
                       From, Nick),
              {(StateData#state.config)#config.allow_visitor_nickchange,
               is_visitor(From, StateData)}} of
-           {_, _, {false, true}} ->
+           {_, _, {false, _}} ->
            Packet1 = Packet#presence{sub_els = [#muc{}]},
            ErrText = <<"Visitors are not allowed to change their "
                    "nicknames in this room">>,

这篇关于从房间配置MUC中删除一些选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆