| CODENOTIFIER | HelpYou are not signed inSign in |
Project: ejabberd-modules
Revision: 702
Author: badlop
Date: 01 Aug 2008 10:59:51
Changes: * src/mod_muc_admin.erl: New commands muc-participants-number and
muc-participants-list
| ... | ...@@ -21,6 +21,8 @@ | |
| 21 | 21 | ctl_process/2, ctl_process/3 % ejabberdctl API |
| 22 | 22 | ]). |
| 23 | 23 | |
| 24 | -compile(export_all). %+++ | |
| 25 | ||
| 24 | 26 | -include("ejabberd.hrl"). |
| 25 | 27 | -include("ejabberd_ctl.hrl"). |
| 26 | 28 | -include("jlib.hrl"). |
| ... | ...@@ -95,6 +97,8 @@ | |
| 95 | 97 | |
| 96 | 98 | commands_global() -> |
| 97 | 99 | [ |
| 100 | {"muc-participants-number room service", "get number of participants in a room"}, | |
| 101 | {"muc-participants-list room service", "get list of participants in a room"}, | |
| 98 | 102 | {"muc-unregister-nick nick", "unregister the nick in the muc service"}, |
| 99 | 103 | {"muc-create-file file", "create the rooms indicated in file"}, |
| 100 | 104 | {"muc-destroy-file file", "destroy the rooms whose JID is indicated in file"}, |
| ... | ...@@ -110,6 +114,26 @@ | |
| 110 | 114 | {"muc-online-rooms", "list existing rooms"} |
| 111 | 115 | ]. |
| 112 | 116 | |
| 117 | ctl_process(_Val, ["muc-participants-number", Room, Service]) -> | |
| 118 | case get_participants_number(Room, Service) of | |
| 119 | Num when is_integer(Num) -> | |
| 120 | io:format("~p~n", [Num]), | |
| 121 | ?STATUS_SUCCESS; | |
| 122 | {error, Error} -> | |
| 123 | io:format("Error getting participants of ~p: ~p~n", [Room, Error]), | |
| 124 | ?STATUS_ERROR | |
| 125 | end; | |
| 126 | ||
| 127 | ctl_process(_Val, ["muc-participants-list", Room, Service]) -> | |
| 128 | case get_participants_list(Room, Service) of | |
| 129 | PartList when is_list(PartList) -> | |
| 130 | [io:format("~s@~s/~s~n", [U, S, R]) || {U, S, R} <- PartList], | |
| 131 | ?STATUS_SUCCESS; | |
| 132 | {error, Error} -> | |
| 133 | io:format("Error getting participants of ~p: ~p~n", [Room, Error]), | |
| 134 | ?STATUS_ERROR | |
| 135 | end; | |
| 136 | ||
| 113 | 137 | ctl_process(_Val, ["muc-unregister-nick", Nick]) -> |
| 114 | 138 | case muc_unregister_nick(Nick) of |
| 115 | 139 | unregistered -> |
| ... | ...@@ -338,6 +362,20 @@ | |
| 338 | 362 | |
| 339 | 363 | |
| 340 | 364 | %%---------------------------- |
| 365 | %% Get Numer of Participants | |
| 366 | %%---------------------------- | |
| 367 | ||
| 368 | get_participants_list(Room, Service) -> | |
| 369 | Pid = get_room_pid(Room, Service), | |
| 370 | S = get_room_state(Pid), | |
| 371 | dict:fetch_keys(S#state.users). | |
| 372 | ||
| 373 | get_participants_number(Room, Service) -> | |
| 374 | List = get_participants_list(Room, Service), | |
| 375 | length(List). | |
| 376 | ||
| 377 | ||
| 378 | %%---------------------------- | |
| 341 | 379 | %% Create/Delete Room |
| 342 | 380 | %%---------------------------- |
| 343 | 381 |
| ... | ...@@ -1,3 +1,8 @@ | |
| 1 | 2008-08-01 Badlop <badlop@process-one.net> | |
| 2 | ||
| 3 | * src/mod_muc_admin.erl: New commands muc-participants-number and | |
| 4 | muc-participants-list | |
| 5 | ||
| 1 | 6 | 2008-05-16 Badlop <badlop@process-one.net> |
| 2 | 7 | |
| 3 | 8 | * src/mod_muc_admin.erl: New exported function |
| ... | ...@@ -5,7 +5,7 @@ | |
| 5 | 5 | Homepage: http://www.ejabberd.im/mod_muc_admin |
| 6 | 6 | Author: Badlop |
| 7 | 7 | This module requires ejabberd 1.1.x for the basic functionality |
| 8 | and ejabberd 2.0.0 or newer to get all the functionality | |
| 8 | and ejabberd 2.0.0 or 2.0.1 or newer to get all the functionality | |
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | CONFIGURATION |