[ejabberd] Roster Additions

Badlop badlop at safe-mail.net
Tue Dec 7 00:00:51 MSK 2004

Johnny Matthews wrote:
> Now I would like to add 
> all of the users to all of the other users' rosters. Is this possible 
> and can you do it with Net::Jabber?

I wrote some time ago a little Erlang program that modifies your 
ejabberd Mnesia database directly and makes exactly what you want.
Since it modifies the local database, al the users must be local users.

1. This code was written by a novice Erlang coder.
2. This code modifies your Mnesia database, it does not use ejabberd 
high level functions. This means that this code is only compatible with 
ejabberd from 0.7.5 to current CVS 5-dec-2004.
3. This code has not been reviewed by anybody with Erlang or ejabberd 
knowledge, so it can contain errors.
4. This code has not been checked on a production server. I tested it on 
my personal server, and it worked perfectly, so I thought it was ok.

How to use it:

1 Create roster.txt

Go to the directory where ejabberd beam files are and create a new file 
called roster.txt. That file must contain something like this:

{"jabber.mycomany.com", [
   {"worker1", "workers"},
   {"worker2", "workers"},
   {"director", "direction"},
   {"president", "direction"}]}.


  * jabber.mycomany.com is your Jabber server
  * worker1, worker2... are the username part of user's JIDs
  * workers, direction: is the group where every user should appear on 
everybody else roster.

2 Prepare pushroster.erl

Copy pushroster.erl to the same directory.

3 Ejabberd

You need access to an Erlang console attached to ejabberd. The easiest 
way to achieve this is to run ejabberd without '-detached', so you will 
have access to the Erlang console.

When ejabberd finish to load and show messages, compile the program:


If there were no errors, now you can start the program:


You can stop the server:


When the users login, they will have their contacts already added and 
accepted on the desired directories.

You can try that program on a test server, or analyze it and write your 
own Perl script.


More information about the ejabberd mailing list