Add functions to list all rooms and participants from database
- Added DB configuration for direct MySQL access - Added list_all_rooms() function: lists all Talk rooms and saves to rooms.txt - Added list_room_participants() function: lists participants of a specific room - Added room type legend (0=1:1, 1=group, 2=public, 3=private, 7=federated) - Added new menu options: 9 (list rooms), A (list participants), D (debug) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@ -9,6 +9,15 @@ YELLOW='\033[1;33m'
|
|||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# DATENBANK KONFIGURATION (für Raum-Liste)
|
||||||
|
# ============================================================================
|
||||||
|
DB_HOST="localhost"
|
||||||
|
DB_USER="d037e856"
|
||||||
|
DB_PASS="aUVp7cvBdKyKac5HGmsw"
|
||||||
|
DB_NAME="d037e856"
|
||||||
|
DB_PREFIX="kwcL2_"
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# INITIALISIERUNG
|
# INITIALISIERUNG
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@ -61,6 +70,105 @@ validate_user() {
|
|||||||
$NC_OCC user:list 2>/dev/null | grep -qw "$1"
|
$NC_OCC user:list 2>/dev/null | grep -qw "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Raum-Typen Erklärung (für Nextcloud Talk)
|
||||||
|
# 0 = 1:1 Chat (Einzelgespräch)
|
||||||
|
# 1 = Gruppen-Chat
|
||||||
|
# 2 = Öffentlicher Raum
|
||||||
|
# 3 = Privater Raum
|
||||||
|
# 7 = Föderierter Raum (in neueren Versionen)
|
||||||
|
|
||||||
|
list_all_rooms() {
|
||||||
|
show_menu
|
||||||
|
echo -e "\n${YELLOW}Alle Talk-Räume aus Datenbank auflisten${NC}\n"
|
||||||
|
|
||||||
|
local output_file="./rooms.txt"
|
||||||
|
local table_name="${DB_PREFIX}talk_rooms"
|
||||||
|
|
||||||
|
echo "Lese Räume aus Datenbank..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# MySQL-Befehl ausführen
|
||||||
|
local mysql_cmd="mysql -h $DB_HOST -u $DB_USER -p'$DB_PASS' $DB_NAME"
|
||||||
|
local query="SELECT token AS Token, name AS Name, type AS Typ, id AS ID FROM \`$table_name\` ORDER BY name ASC"
|
||||||
|
|
||||||
|
$mysql_cmd -e "$query" 2>/dev/null > "$output_file"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Fehler: Konnte nicht auf die Datenbank zugreifen!${NC}"
|
||||||
|
echo -e "Versuche alternative Tabellennamen..."
|
||||||
|
|
||||||
|
# Alternative Tabellen versuchen
|
||||||
|
for alt_table in "${DB_PREFIX}spreed_rooms" "${DB_PREFIX}oc_talk_rooms" "${DB_PREFIX}oc_spreed_rooms"; do
|
||||||
|
$mysql_cmd -e "SELECT token AS Token, name AS Name, type AS Typ, id AS ID FROM \`$alt_table\` ORDER BY name ASC" 2>/dev/null > "$output_file"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
table_name="$alt_table"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -s "$output_file" ]; then
|
||||||
|
echo -e "${RED}Fehler: Keine Talk-Räume gefunden!${NC}"
|
||||||
|
rm -f "$output_file"
|
||||||
|
read -p "Enter..." && return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ausgabe anzeigen
|
||||||
|
echo -e "${GREEN}=================================================================${NC}"
|
||||||
|
echo -e "${GREEN} Nextcloud Talk Räume (gespeichert in $output_file)${NC}"
|
||||||
|
echo -e "${GREEN}=================================================================${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Typ-Legende:"
|
||||||
|
echo " 0 = 1:1 Chat (Einzelgespräch)"
|
||||||
|
echo " 1 = Gruppen-Chat"
|
||||||
|
echo " 2 = Öffentlicher Raum"
|
||||||
|
echo " 3 = Privater Raum"
|
||||||
|
echo " 7 = Föderierter Raum"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
cat "$output_file"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}Die Liste wurde in $output_file gespeichert.${NC}"
|
||||||
|
read -p "Enter..."
|
||||||
|
}
|
||||||
|
|
||||||
|
list_room_participants() {
|
||||||
|
show_menu
|
||||||
|
echo -e "\n${YELLOW}Teilnehmer eines Chats auflisten${NC}\n"
|
||||||
|
read -p "Token des Chatraums: " room_token
|
||||||
|
[ -z "$room_token" ] && echo -e "${RED}Fehler!${NC}" && read -p "Enter..." && return
|
||||||
|
|
||||||
|
# Erst die Raum-ID aus der Datenbank holen
|
||||||
|
local mysql_cmd="mysql -h $DB_HOST -u $DB_USER -p'$DB_PASS' $DB_NAME"
|
||||||
|
local room_id=$($mysql_cmd -N -e "SELECT id FROM \`${DB_PREFIX}talk_rooms\` WHERE token = '$room_token'" 2>/dev/null)
|
||||||
|
|
||||||
|
if [ -z "$room_id" ]; then
|
||||||
|
echo -e "${RED}Fehler: Chat mit Token '$room_token' nicht gefunden!${NC}"
|
||||||
|
read -p "Enter..." && return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Teilnehmer abfragen
|
||||||
|
local table_name="${DB_PREFIX}talk_rooms_attendees"
|
||||||
|
echo ""
|
||||||
|
echo "Teilnehmer des Chats '$room_token':"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
$mysql_cmd -e "SELECT a.actor_id AS UserID, u.uid AS Username FROM \`$table_name\` a LEFT JOIN \`${DB_PREFIX}users\` u ON a.actor_id = u.uid WHERE a.room_id = '$room_id' AND a.actor_type = 'users'" 2>/dev/null
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
# Alternative Tabellen versuchen
|
||||||
|
for alt_table in "${DB_PREFIX}spreed_rooms_attendees" "${DB_PREFIX}talk_room_participants" "${DB_PREFIX}oc_talk_rooms_attendees"; do
|
||||||
|
$mysql_cmd -e "SELECT a.actor_id AS UserID, u.uid AS Username FROM \`$alt_table\` a LEFT JOIN \`${DB_PREFIX}users\` u ON a.actor_id = u.uid WHERE a.room_id = '$room_id' AND a.actor_type = 'users'" 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
read -p "Enter..."
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# MENÜ
|
# MENÜ
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@ -79,7 +187,9 @@ show_menu() {
|
|||||||
echo -e "${YELLOW}6.${NC} Chat sperren (read-only)"
|
echo -e "${YELLOW}6.${NC} Chat sperren (read-only)"
|
||||||
echo -e "${YELLOW}7.${NC} Chat entsperren"
|
echo -e "${YELLOW}7.${NC} Chat entsperren"
|
||||||
echo -e "${YELLOW}8.${NC} Chat-Info anzeigen"
|
echo -e "${YELLOW}8.${NC} Chat-Info anzeigen"
|
||||||
echo -e "${YELLOW}9.${NC} Debug-Informationen"
|
echo -e "${YELLOW}9.${NC} Alle Räume auflisten (-> rooms.txt)"
|
||||||
|
echo -e "${YELLOW}A.${NC} Teilnehmer eines Chats auflisten"
|
||||||
|
echo -e "${YELLOW}D.${NC} Debug-Informationen"
|
||||||
echo -e "${YELLOW}0.${NC} Beenden"
|
echo -e "${YELLOW}0.${NC} Beenden"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
@ -265,7 +375,7 @@ show_chat_info() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_menu
|
show_menu
|
||||||
read -p "Wählen Sie [0-9,d]: " choice
|
read -p "Wählen Sie [0-9,A,D]: " choice
|
||||||
case $choice in
|
case $choice in
|
||||||
1) create_chat ;;
|
1) create_chat ;;
|
||||||
2) add_user_to_chat ;;
|
2) add_user_to_chat ;;
|
||||||
@ -275,7 +385,9 @@ while true; do
|
|||||||
6) lock_chat ;;
|
6) lock_chat ;;
|
||||||
7) unlock_chat ;;
|
7) unlock_chat ;;
|
||||||
8) show_chat_info ;;
|
8) show_chat_info ;;
|
||||||
9) show_debug ;;
|
9) list_all_rooms ;;
|
||||||
|
A|a) list_room_participants ;;
|
||||||
|
D|d) show_debug ;;
|
||||||
0) echo -e "\n${GREEN}Auf Wiedersehen!${NC}" && exit 0 ;;
|
0) echo -e "\n${GREEN}Auf Wiedersehen!${NC}" && exit 0 ;;
|
||||||
*) echo -e "${RED}Ungültige Auswahl!${NC}" ;;
|
*) echo -e "${RED}Ungültige Auswahl!${NC}" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user