Fix bash function xmpp_send_server_notice_all()

This commit is contained in:
pitchum 2022-12-24 08:46:30 +01:00 committed by root
parent 1b65fc9bdd
commit d5a542cf97
2 changed files with 2 additions and 55 deletions

View File

@ -1,52 +0,0 @@
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_user_by_patern() {
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() {
sudo -u ejabberd ejabberdctl send_message headline xmpp-admin@chapril.org \
chapril.org/announce/online "Annonce du Serveur" "${1}"
}
xmpp_send_server_notice_to_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_by_pattern() {
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" "Annonce du Serveur" "${2}"
echo Done with $ADDRESS
done
}

View File

@ -27,8 +27,7 @@ xmpp_ban_users() {
} }
xmpp_send_server_notice_all() { xmpp_send_server_notice_all() {
sudo -u ejabberd ejabberdctl send_message headline xmpp-admin@chapril.org \ sudo -u ejabberd ejabberdctl send_message chat chapril.org chapril.org/announce/online "Annonce du Serveur" "${1}"
chapril.org/announce/online "Annonce du Serveur" "${1}"
} }
xmpp_send_server_notice_connected() { xmpp_send_server_notice_connected() {
@ -41,7 +40,7 @@ xmpp_send_server_notice_connected() {
done done
} }
xmpp_send_server_notice() { xmpp_send_server_notice_pattern() {
LIST=$(sudo -u ejabberd ejabberdctl registered_users chapril.org | grep ${1} | uniq) LIST=$(sudo -u ejabberd ejabberdctl registered_users chapril.org | grep ${1} | uniq)
for ADDRESS in $LIST for ADDRESS in $LIST