xmpp.chapril.org-tools/useful_functions/functions.sh

52 lines
1.5 KiB
Bash
Raw Normal View History

2021-03-26 23:57:31 +01:00
xmpp_user_rooms_count() {
sudo -u ejabberd ejabberdctl get_user_rooms ${1} chapril.org | wc -l
}
xmpp_user_contacts_count() {
sudo -u ejabberd ejabberdctl get_roster ${1} chapril.org | wc -l
}
xmpp_user_info() {
echo "${1}:$(xmpp_user_contacts_count ${1}):$(xmpp_user_rooms_count ${1})"
}
xmpp_users() {
for user in $(sudo -u ejabberd ejabberdctl registered_users chapril.org); do
xmpp_user_info "${user}"
done
}
xmpp_ban_users() {
LIST=$(sudo -u ejabberd ejabberdctl registered_users chapril.org | grep ${1} | uniq)
for ADDRESS in $LIST
do
sudo -u ejabberd ejabberdctl kick_user $ADDRESS chapril.org
sudo -u ejabberd ejabberdctl unregister $ADDRESS chapril.org
echo Done with $ADDRESS
done
}
xmpp_send_server_notice_all() {
sudo -u ejabberd ejabberdctl send_message chat chapril.org chapril.org/announce/online "Annonce du Serveur" "${1}"
2021-03-26 23:57:31 +01:00
}
xmpp_send_server_notice_connected() {
LIST=$(sudo -u ejabberd ejabberdctl connected_users_info | cut -f 1 | cut -d "/" -f 1 | uniq)
for ADDRESS in $LIST
do
sudo -u ejabberd ejabberdctl send_message headline chapril.org "$ADDRESS" "Annonce du Serveur" "${2}"
echo Done with $ADDRESS
done
}
xmpp_send_server_notice_pattern() {
2021-03-26 23:57:31 +01:00
LIST=$(sudo -u ejabberd ejabberdctl registered_users chapril.org | grep ${1} | uniq)
for ADDRESS in $LIST
do
sudo -u ejabberd ejabberdctl send_message headline chapril.org "${ADDRESS}@chapril.org" "Annonce du Serveur" "${2}"
echo Done with $ADDRESS
done
}