FINAL FIX: Alle Talk-Kommandos für Nextcloud 34 komplett korrigiert

- talk:chat:create -> talk:room:create (endgültig)
- talk:participant:* -> talk:room:add/remove (endgültig)
- talk:moderator:* -> talk:room:promote/demote (endgültig)
- talk:room:read-only -> talk:room:update --read-only= (endgültig)
- validate_room verwendet talk:monitor:room mit besserer Logik
- talk:room:list komplett entfernt (nicht verfügbar in NC34)
- show_chat_info verwendet talk:monitor:room

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
wralto-user-1
2026-10-30 16:22:51 +01:00
parent 7f4398df1b
commit 7418a62f3e

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
# Nextcloud Talk Chat-Verwaltungsscript (Nextcloud 34 Final Edition) # Nextcloud Talk Chat-Verwaltungsscript (Nextcloud 34 - FINAL FIXED)
# #
# Kompatibel mit Nextcloud 34.x (Talk-App als "spreed") # Kompatibel mit Nextcloud 34.x
# Alle Befehle angepasst an die neue Talk-App CLI # Alle Talk-Kommandos angepasst an die neue CLI
# #
# FÜHRUNGSHINWEISE: # FÜHRUNGSHINWEISE:
# 1. Führe dieses Script AUF DEM NEXTcloud-SERVER aus # 1. Führe dieses Script AUF DEM NEXTcloud-SERVER aus
@ -14,42 +14,29 @@
# cd /pfad/zu/nextcloud # cd /pfad/zu/nextcloud
# sudo ./nextcloud_talk_manager.sh # sudo ./nextcloud_talk_manager.sh
# Farben für bessere Lesbarkeit # Farben
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
NC='\033[0m' # No Color NC='\033[0m'
# Prüfe ob wir uns bereits im Nextcloud-Verzeichnis befinden # ============================================================================
# INITIALISIERUNG
# ============================================================================
# Nextcloud-Verzeichnis finden
if [ -f "./occ" ] && [ -f "./config/config.php" ]; then if [ -f "./occ" ] && [ -f "./config/config.php" ]; then
NEXTCLOUD_DIR="." NEXTCLOUD_DIR="."
echo -e "${GREEN}Nextcloud-Verzeichnis: aktuelles Verzeichnis (.)${NC}" echo -e "${GREEN}Nextcloud-Verzeichnis: aktuelles Verzeichnis (.)${NC}"
else else
find_nextcloud_dir() { find_nextcloud_dir() {
local possible_paths=( for path in /var/www/nextcloud /var/www/html/nextcloud /usr/share/nextcloud /srv/nextcloud /opt/nextcloud; do
"/var/www/nextcloud" [ -f "$path/occ" ] && [ -f "$path/config/config.php" ] && echo "$path" && return 0
"/var/www/html/nextcloud"
"/usr/share/nextcloud"
"/srv/nextcloud"
"/opt/nextcloud"
)
for path in "${possible_paths[@]}"; do
if [ -f "$path/occ" ] && [ -f "$path/config/config.php" ]; then
echo "$path"
return 0
fi
done done
local occ_path=$(find / -name "occ" -type f 2>/dev/null | while read occ; do find / -name "occ" -type f 2>/dev/null | while read occ; do
if [ -f "$(dirname "$occ")/config/config.php" ]; then [ -f "$(dirname "$occ")/config/config.php" ] && echo "$(dirname "$occ")" && return 0
echo "$(dirname "$occ")" done | head -1
return 0
fi
done | head -1)
if [ -n "$occ_path" ]; then
echo "$occ_path"
return 0
fi
return 1 return 1
} }
if find_nextcloud_dir > /dev/null 2>&1; then if find_nextcloud_dir > /dev/null 2>&1; then
@ -57,21 +44,16 @@ else
echo -e "${GREEN}Nextcloud-Verzeichnis: $NEXTCLOUD_DIR${NC}" echo -e "${GREEN}Nextcloud-Verzeichnis: $NEXTCLOUD_DIR${NC}"
else else
read -p "Nextcloud-Verzeichnis: " NEXTCLOUD_DIR read -p "Nextcloud-Verzeichnis: " NEXTCLOUD_DIR
if [ ! -f "$NEXTCLOUD_DIR/occ" ]; then [ ! -f "$NEXTCLOUD_DIR/occ" ] && echo -e "${RED}Fehler: occ nicht gefunden!${NC}" && exit 1
echo -e "${RED}Fehler: 'occ' nicht in $NEXTCLOUD_DIR gefunden!${NC}"
exit 1
fi
fi fi
fi fi
# Pfad zu PHP finden # PHP finden
PHP_PATH="$(which php 2>/dev/null)" PHP_PATH="$(which php 2>/dev/null)"
if [ -z "$PHP_PATH" ]; then
for php_bin in /usr/bin/php /usr/bin/php8.* /usr/bin/php7.* /usr/local/bin/php; do for php_bin in /usr/bin/php /usr/bin/php8.* /usr/bin/php7.* /usr/local/bin/php; do
[ -x "$php_bin" ] && PHP_PATH="$php_bin" && break [ -x "$php_bin" ] && PHP_PATH="$php_bin" && break
done done
[ -z "$PHP_PATH" ] && echo -e "${RED}Fehler: PHP nicht gefunden!${NC}" && exit 1 [ -z "$PHP_PATH" ] && echo -e "${RED}Fehler: PHP nicht gefunden!${NC}" && exit 1
fi
# Webserver-Benutzer # Webserver-Benutzer
WEB_USER="www-data" WEB_USER="www-data"
@ -80,32 +62,18 @@ id nginx &>/dev/null && WEB_USER="nginx"
# OCC-Befehl # OCC-Befehl
NC_OCC="sudo -u $WEB_USER $PHP_PATH $NEXTCLOUD_DIR/occ" NC_OCC="sudo -u $WEB_USER $PHP_PATH $NEXTCLOUD_DIR/occ"
!$NC_OCC --version > /dev/null 2>&1 && NC_OCC="$PHP_PATH $NEXTCLOUD_DIR/occ"
!$NC_OCC --version > /dev/null 2>&1 && echo -e "${RED}Fehler: OCC funktioniert nicht!${NC}" && exit 1
# Test OCC # Talk-App prüfen
if ! $NC_OCC --version > /dev/null 2>&1; then
NC_OCC="$PHP_PATH $NEXTCLOUD_DIR/occ"
if ! $NC_OCC --version > /dev/null 2>&1; then
echo -e "${RED}Fehler: OCC funktioniert nicht!${NC}" && exit 1
fi
fi
# Prüfe Talk-App
TALK_APP=$($NC_OCC app:list 2>/dev/null | grep -iE "spreed|talk" | head -1) TALK_APP=$($NC_OCC app:list 2>/dev/null | grep -iE "spreed|talk" | head -1)
if [ -z "$TALK_APP" ]; then [ -z "$TALK_APP" ] && echo -e "${RED}Talk-App nicht installiert!${NC}" && read -p "Installieren? (j/n): " && [ "$REPLY" = "j" ] && $NC_OCC app:install spreed && $NC_OCC app:enable spreed
echo -e "${RED}Talk-App nicht installiert!${NC}"
read -p "Installieren? (j/n) [n]: " install
[ "$install" = "j" ] && $NC_OCC app:install spreed && $NC_OCC app:enable spreed
fi
# Prüfe Upgrade # Upgrade prüfen
if $NC_OCC status 2>/dev/null | grep -qi "require upgrade"; then $NC_OCC status 2>/dev/null | grep -qi "require upgrade" && read -p "Upgrade durchführen? (j/n) [j]: " && [ "$REPLY" = "j" ] || [ -z "$REPLY" ] && $NC_OCC upgrade
echo -e "${RED}Upgrade erforderlich!${NC}"
read -p "Upgrade jetzt? (j/n) [j]: " do_upgrade
[ "$do_upgrade" = "j" ] || [ -z "$do_upgrade" ] && $NC_OCC upgrade
fi
# ============================================================================ # ============================================================================
# KERN FUNKTIONEN # KERN FUNKTIONEN (NUR NEXTCLOUD 34 KOMPATIBEL)
# ============================================================================ # ============================================================================
# Raum validieren - NUTZT talk:monitor:room # Raum validieren - NUTZT talk:monitor:room
@ -117,18 +85,13 @@ validate_room() {
result=$($NC_OCC talk:monitor:room "$room_token" 2>&1) result=$($NC_OCC talk:monitor:room "$room_token" 2>&1)
exit_code=$? exit_code=$?
# Prüfe auf Fehlerwörter in der Ausgabe # Wenn Ausgabe typische talk:monitor:room Inhalte hat, existiert der Raum
if echo "$result" | grep -qi "does not exist\|not found\|invalid\|unknown\|error"; then
return 1
fi
# Prüfe auf erfolgreiche Ausgabe (enthält typische talk:monitor:room Ausgabe)
if echo "$result" | grep -qi "conversation\|attendees\|sessions\|has \|with "; then if echo "$result" | grep -qi "conversation\|attendees\|sessions\|has \|with "; then
return 0 return 0
fi fi
# Wenn exit_code 0 ist und keine Fehlerwörter, dann existiert der Raum # Wenn keine Fehlerwörter und exit_code 0, dann existiert
if [ $exit_code -eq 0 ]; then if ! echo "$result" | grep -qi "does not exist\|not found\|invalid\|unknown\|error" && [ $exit_code -eq 0 ]; then
return 0 return 0
fi fi
@ -145,60 +108,8 @@ get_user_id() {
$NC_OCC user:list --output=json 2>/dev/null | grep -A2 "\"$1\"" | grep '"id"' | head -1 | cut -d'"' -f4 $NC_OCC user:list --output=json 2>/dev/null | grep -A2 "\"$1\"" | grep '"id"' | head -1 | cut -d'"' -f4
} }
# Raum auflisten (mehrere Methoden)
list_rooms() {
# Methode 1: Versuche API v4
local api_result
api_result=$(curl -s -H "OCS-APIRequest: true" -u admin:admin "http://localhost/ocs/v2.php/apps/spreed/api/v4/room" 2>/dev/null)
if echo "$api_result" | grep -q '<ocs>'; then
echo "$api_result" | grep -oP '<token>\K[^<]+'
return 0
fi
# Methode 2: Datenbank (wenn config lesbar)
local db_type=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbtype 2>/dev/null)
local db_name=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbname 2>/dev/null)
local db_user=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbuser 2>/dev/null)
local db_host=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbhost 2>/dev/null)
if [ -n "$db_name" ]; then
# Versuche MySQL
if [ "$db_type" = "mysql" ] || [ "$db_type" = "mariadb" ]; then
local db_pass=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbpassword 2>/dev/null)
local result=$(mysql -h "$db_host" -u "$db_user" -p"$db_pass" -N -e "SELECT token FROM oc_talk_rooms" "$db_name" 2>/dev/null)
[ -n "$result" ] && echo "$result" && return 0
fi
# Versuche PostgreSQL
if [ "$db_type" = "pgsql" ]; then
local db_pass=$(sudo -u www-data $PHP_PATH $NEXTCLOUD_DIR/occ config:system:get dbpassword 2>/dev/null)
local result=$(PGPASSWORD="$db_pass" psql -h "$db_host" -U "$db_user" -d "$db_name" -t -c "SELECT token FROM oc_talk_rooms" 2>/dev/null)
[ -n "$result" ] && echo "$result" | sed 's/^ *//' | sed 's/ *$//' && return 0
fi
# Versuche SQLite
if [ "$db_type" = "sqlite" ]; then
local db_file="${NEXTCLOUD_DIR}/data/nextcloud.db"
[ -f "$db_file" ] && sqlite3 "$db_file" "SELECT token FROM oc_talk_rooms" 2>/dev/null && return 0
fi
fi
# Methode 3: Gib Anleitung
echo ""
echo -e "${YELLOW}Manuelle Methoden zum Auflisten von Chats:${NC}"
echo ""
echo "1. API (empfohlen):"
echo " curl -H 'OCS-APIRequest: true' -u admin:pass 'http://localhost/ocs/v2.php/apps/spreed/api/v4/room'"
echo ""
echo "2. Datenbank:"
echo " mysql -u dbuser -p -e 'SELECT token, name FROM oc_talk_rooms' dbname"
echo ""
return 1
}
# ============================================================================ # ============================================================================
# MENÜ & FUNKTIONEN # MENÜ
# ============================================================================ # ============================================================================
show_menu() { show_menu() {
@ -214,8 +125,7 @@ show_menu() {
echo -e "${YELLOW}5.${NC} Moderatorenrechte entziehen" echo -e "${YELLOW}5.${NC} Moderatorenrechte entziehen"
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} Alle Chats auflisten" echo -e "${YELLOW}8.${NC} Chat-Info anzeigen"
echo -e "${YELLOW}9.${NC} Chat-Info anzeigen"
echo -e "${YELLOW}d.${NC} Debug-Informationen" echo -e "${YELLOW}d.${NC} Debug-Informationen"
echo -e "${YELLOW}0.${NC} Beenden" echo -e "${YELLOW}0.${NC} Beenden"
echo "" echo ""
@ -226,10 +136,9 @@ show_debug() {
echo -e "${BLUE}=== Debug-Informationen ===${NC}\n" echo -e "${BLUE}=== Debug-Informationen ===${NC}\n"
echo "Nextcloud: $NEXTCLOUD_DIR" echo "Nextcloud: $NEXTCLOUD_DIR"
echo "PHP: $PHP_PATH" echo "PHP: $PHP_PATH"
echo "User: $WEB_USER"
echo "OCC: $NC_OCC" echo "OCC: $NC_OCC"
echo "" echo ""
echo -e "${YELLOW}Talk-App Status:${NC}" echo -e "${YELLOW}Talk-App:${NC}"
$NC_OCC app:list | grep -iE "spreed|talk" $NC_OCC app:list | grep -iE "spreed|talk"
echo "" echo ""
echo -e "${YELLOW}Teste Raum-Validierung (iba4cezy):${NC}" echo -e "${YELLOW}Teste Raum-Validierung (iba4cezy):${NC}"
@ -237,16 +146,17 @@ show_debug() {
echo "✓ Chat existiert" echo "✓ Chat existiert"
else else
echo "✗ Chat existiert NICHT" echo "✗ Chat existiert NICHT"
echo "Teste manuell: $NC_OCC talk:monitor:room iba4cezy" echo "Manueller Test:"
$NC_OCC talk:monitor:room iba4cezy $NC_OCC talk:monitor:room iba4cezy
fi fi
echo "" echo ""
echo -e "${YELLOW}Verfügbare Talk-Kommandos:${NC}" read -p "Drücken Sie Enter..."
$NC_OCC talk: 2>&1 | grep -E ":" | head -20
echo ""
read -p "Drücken Sie Enter zum Fortfahren..."
} }
# ============================================================================
# CHAT FUNKTIONEN (ALLE ANGEPASST FÜR NEXTCLOUD 34)
# ============================================================================
create_chat() { create_chat() {
show_menu show_menu
echo -e "\n${YELLOW}Chat anlegen${NC}\n" echo -e "\n${YELLOW}Chat anlegen${NC}\n"
@ -261,28 +171,21 @@ create_chat() {
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:create \"$chat_name\" --type=$chat_type${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:create \"$chat_name\" --type=$chat_type${NC}"
local result=$($NC_OCC talk:room:create "$chat_name" --type="$chat_type" 2>&1) local result=$($NC_OCC talk:room:create "$chat_name" --type="$chat_type" 2>&1)
local exit_code=$?
echo "Exit-Code: $exit_code" echo "Exit-Code: $?"
echo "Output: $result" echo "Output: $result"
if [ $exit_code -ne 0 ]; then # Token extrahieren
echo -e "${RED}Fehler beim Anlegen!${NC}"
read -p "Enter..." && return
fi
# Token extrahieren - Nextcloud 34 gibt den Token in der Ausgabe zurück
local room_token=$(echo "$result" | grep -oE '[a-zA-Z0-9]{8,}') local room_token=$(echo "$result" | grep -oE '[a-zA-Z0-9]{8,}')
if [ -z "$room_token" ]; then if [ -z "$room_token" ]; then
echo -e "${RED}Token nicht gefunden. Bitte manuell aus Ausgabe entnehmen.${NC}" echo -e "${RED}Token nicht extrahiert. Bitte manuell aus Ausgabe entnehmen.${NC}"
echo "Rohausgabe: $result"
read -p "Enter..." && return read -p "Enter..." && return
fi fi
echo -e "${GREEN}Chat Token: $room_token${NC}" echo -e "${GREEN}Chat Token: $room_token${NC}"
# Nutzer hinzufügen # Nutzer hinzufügen
if [ -n "$room_token" ] && [ -n "$users_to_add" ]; then if [ -n "$users_to_add" ]; then
IFS=',' read -ra users <<< "$users_to_add" IFS=',' read -ra users <<< "$users_to_add"
for user in "${users[@]}"; do for user in "${users[@]}"; do
user=$(echo "$user" | tr -d ' ') user=$(echo "$user" | tr -d ' ')
@ -300,7 +203,6 @@ create_chat() {
done done
fi fi
echo -e "${GREEN}Chat angelegt! Token: $room_token${NC}"
read -p "Enter..." read -p "Enter..."
} }
@ -319,33 +221,18 @@ add_user_to_chat() {
read -p "Enter..." && return read -p "Enter..." && return
fi fi
# Versuche Raum zu validieren
if ! validate_room "$room_token"; then if ! validate_room "$room_token"; then
# Falls validate_room scheitert, teste direkt mit talk:monitor:room
echo -e "${YELLOW}Teste Raum manuell...${NC}"
local test_result=$($NC_OCC talk:monitor:room "$room_token" 2>&1)
echo "Test-Ergebnis: $test_result"
if echo "$test_result" | grep -qi "does not exist\|not found\|invalid"; then
echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}" echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}"
echo "Manueller Test: $NC_OCC talk:monitor:room $room_token"
$NC_OCC talk:monitor:room "$room_token" 2>&1
read -p "Enter..." && return read -p "Enter..." && return
fi fi
fi
local user_id=$(get_user_id "$username") local user_id=$(get_user_id "$username")
if [ -z "$user_id" ]; then [ -z "$user_id" ] && echo -e "${RED}User-ID nicht gefunden!${NC}" && read -p "Enter..." && return
echo -e "${RED}User-ID für '$username' nicht gefunden!${NC}"
read -p "Enter..." && return
fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:add $room_token $user_id${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:add $room_token $user_id${NC}"
local result=$($NC_OCC talk:room:add "$room_token" "$user_id" 2>&1) $NC_OCC talk:room:add "$room_token" "$user_id" 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Nutzer $username hinzugefügt!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -367,26 +254,14 @@ remove_user_from_chat() {
if ! validate_room "$room_token"; then if ! validate_room "$room_token"; then
echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}" echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}"
echo "Teste manuell: $NC_OCC talk:monitor:room $room_token"
$NC_OCC talk:monitor:room "$room_token" 2>&1
read -p "Enter..." && return read -p "Enter..." && return
fi fi
local user_id=$(get_user_id "$username") local user_id=$(get_user_id "$username")
if [ -z "$user_id" ]; then [ -z "$user_id" ] && echo -e "${RED}User-ID nicht gefunden!${NC}" && read -p "Enter..." && return
echo -e "${RED}User-ID für '$username' nicht gefunden!${NC}"
read -p "Enter..." && return
fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:remove $room_token $user_id${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:remove $room_token $user_id${NC}"
local result=$($NC_OCC talk:room:remove "$room_token" "$user_id" 2>&1) $NC_OCC talk:room:remove "$room_token" "$user_id" 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Nutzer $username entfernt!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -408,26 +283,14 @@ make_moderator() {
if ! validate_room "$room_token"; then if ! validate_room "$room_token"; then
echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}" echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}"
echo "Teste manuell: $NC_OCC talk:monitor:room $room_token"
$NC_OCC talk:monitor:room "$room_token" 2>&1
read -p "Enter..." && return read -p "Enter..." && return
fi fi
local user_id=$(get_user_id "$username") local user_id=$(get_user_id "$username")
if [ -z "$user_id" ]; then [ -z "$user_id" ] && echo -e "${RED}User-ID nicht gefunden!${NC}" && read -p "Enter..." && return
echo -e "${RED}User-ID für '$username' nicht gefunden!${NC}"
read -p "Enter..." && return
fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:promote $room_token $user_id${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:promote $room_token $user_id${NC}"
local result=$($NC_OCC talk:room:promote "$room_token" "$user_id" 2>&1) $NC_OCC talk:room:promote "$room_token" "$user_id" 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}$username ist jetzt Moderator!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -449,26 +312,14 @@ remove_moderator() {
if ! validate_room "$room_token"; then if ! validate_room "$room_token"; then
echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}" echo -e "${RED}Chat mit Token '$room_token' existiert nicht!${NC}"
echo "Teste manuell: $NC_OCC talk:monitor:room $room_token"
$NC_OCC talk:monitor:room "$room_token" 2>&1
read -p "Enter..." && return read -p "Enter..." && return
fi fi
local user_id=$(get_user_id "$username") local user_id=$(get_user_id "$username")
if [ -z "$user_id" ]; then [ -z "$user_id" ] && echo -e "${RED}User-ID nicht gefunden!${NC}" && read -p "Enter..." && return
echo -e "${RED}User-ID für '$username' nicht gefunden!${NC}"
read -p "Enter..." && return
fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:demote $room_token $user_id${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:demote $room_token $user_id${NC}"
local result=$($NC_OCC talk:room:demote "$room_token" "$user_id" 2>&1) $NC_OCC talk:room:demote "$room_token" "$user_id" 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Moderatorenrechte von $username entfernt!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -486,14 +337,7 @@ lock_chat() {
fi fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:update $room_token --read-only=1${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:update $room_token --read-only=1${NC}"
local result=$($NC_OCC talk:room:update "$room_token" --read-only=1 2>&1) $NC_OCC talk:room:update "$room_token" --read-only=1 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Chat gesperrt!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -511,35 +355,7 @@ unlock_chat() {
fi fi
echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:update $room_token --read-only=0${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:room:update $room_token --read-only=0${NC}"
local result=$($NC_OCC talk:room:update "$room_token" --read-only=0 2>&1) $NC_OCC talk:room:update "$room_token" --read-only=0 2>&1
echo "Output: $result"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Chat entsperrt!${NC}"
else
echo -e "${RED}Fehler: $result${NC}"
fi
read -p "Enter..."
}
list_chats() {
show_menu
echo -e "\n${YELLOW}Alle Chats auflisten${NC}\n"
echo -e "${BLUE}Versuche Chats aufzulisten...${NC}"
local rooms
rooms=$(list_rooms 2>&1)
if [ -n "$rooms" ]; then
echo -e "\n${GREEN}Gefundene Chats:${NC}"
echo "$rooms"
else
echo -e "${YELLOW}Keine Chats gefunden oder Methode fehlgeschlagen.${NC}"
echo "Verfügbare Methoden:"
echo " 1. API: curl -H 'OCS-APIRequest: true' -u admin:pass 'http://localhost/ocs/v2.php/apps/spreed/api/v4/room'"
echo " 2. Datenbank: SELECT token, name FROM oc_talk_rooms"
fi
read -p "Enter..." read -p "Enter..."
} }
@ -552,12 +368,7 @@ show_chat_info() {
[ -z "$room_token" ] && echo -e "${RED}Fehler: Token leer!${NC}" && read -p "Enter..." && return [ -z "$room_token" ] && echo -e "${RED}Fehler: Token leer!${NC}" && read -p "Enter..." && return
echo -e "\n${BLUE}Befehl: $NC_OCC talk:monitor:room $room_token${NC}" echo -e "\n${BLUE}Befehl: $NC_OCC talk:monitor:room $room_token${NC}"
local result=$($NC_OCC talk:monitor:room "$room_token" 2>&1) $NC_OCC talk:monitor:room "$room_token" 2>&1
local exit_code=$?
echo "Exit-Code: $exit_code"
echo ""
echo "$result"
read -p "Enter..." read -p "Enter..."
} }
@ -577,8 +388,7 @@ while true; do
5) remove_moderator ;; 5) remove_moderator ;;
6) lock_chat ;; 6) lock_chat ;;
7) unlock_chat ;; 7) unlock_chat ;;
8) list_chats ;; 8) show_chat_info ;;
9) show_chat_info ;;
d) show_debug ;; 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}" ;;