I want to set different message interval for some muc(Multi-User Chat) in ejabberd. I know min_message_interval option for all muc. But I want set different interval for some muc. For example, I want create a room(muc room) which min message interval is 1 message per second. and another room message interval is 5 message per second. Is this possible and how?
The option min_message_interval is defined for the whole mod_muc service, so it doesn't help for your purpose. And the rooms do not have an equivalent option that you could set per-room.
The good news is that I found a dirty solution: use an existing room option for your purposes...
First: You would need to download ejabberd source code (recent 21.04 version) and apply this patch:
diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 2fa08dc79..0ced5429b 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -309,7 +309,7 @@ normal_state({route, <<"">>,
true when Type == groupchat ->
Activity = get_user_activity(From, StateData),
Now = erlang:system_time(microsecond),
- MinMessageInterval = trunc(mod_muc_opt:min_message_interval(StateData#state.server_host) * 1000000),
+ MinMessageInterval = trunc((StateData#state.config)#config.voice_request_min_interval* 1000),
Size = element_size(Packet),
{MessageShaper, MessageShaperInterval} =
ejabberd_shaper:update(Activity#activity.message_shaper, Size),
@@ -1744,7 +1744,7 @@ get_user_activity(JID, StateData) ->
-spec store_user_activity(jid(), #activity{}, state()) -> state().
store_user_activity(JID, UserActivity, StateData) ->
MinMessageInterval =
- trunc(mod_muc_opt:min_message_interval(StateData#state.server_host) * 1000),
+ trunc((StateData#state.config)#config.voice_request_min_interval),
MinPresenceInterval =
trunc(mod_muc_opt:min_presence_interval(StateData#state.server_host) * 1000),
Key = jid:tolower(JID),
Recompile ejabberd, install, and start.
Now change a room configuration using a jabber client, or using "ejabberdctl change_room_option". Concretely change the option voice_request_min_interval. Each room can have a different value...
ejabberd will use that option to determine the minimum message interval, instead of the mod_muc option.