En iyi Webmaster forumlari.
iyilerin buluşma noktasi.

Musteriserv botu

Başlatan Administrator, Tem 27, 2025, 08:23 ÖÖ

« önceki - sonraki »

Administrator

set destek_dosyasi "data/destek.txt"
set yanit_dosyasi "data/yanitlar.txt"
set adminler {Erkan Mehmet}

bind msg - "!destek" musteri_destek_ozel
bind pub - "!destek" musteri_destek_kanal
bind pubm - "!yanitla" destek_yanitla
bind pub - "!istatistik" destek_istatistik

proc musteri_destek_ozel {nick uhost handle text} {
    destek_talep $nick $text "PRIVMSG $nick"
}
proc musteri_destek_kanal {nick uhost handle chan text} {
    destek_talep $nick $text "PRIVMSG $chan"
}

proc destek_talep {nick mesaj replycmd} {
    set mesaj [string trim $mesaj]
    if {$mesaj eq ""} {
        putquick "$replycmd :❗ Lütfen bir mesaj girin: !destek <sorun>"
        return
    }
    set id "[clock seconds]-[rand 1000 9999]"
    set durum "Açık"

    set f [open $::destek_dosyasi a]
    puts $f "$id|$nick|$mesaj|$durum"
    close $f

    putquick "$replycmd :✅ Talebiniz alındı. Ticket ID: $id"
    foreach admin $::adminler {
        putquick "PRIVMSG $admin :📩 Yeni destek talebi: $id | $nick | $mesaj"
    }
}

# Admin yanıt verir: !yanitla <id> <mesaj>
proc destek_yanitla {nick uhost handle chan text} {
    if {[lsearch -exact $::adminler $nick] == -1} return

    set args [split $text " "]
    set id [lindex $args 0]
    set yanit [join [lrange $args 1 end] " "]

    if {$id eq "" || $yanit eq ""} {
        putquick "PRIVMSG $chan :❗ Kullanım: !yanitla <ticket_id> <mesaj>"
        return
    }

    # Destek kaydını oku
    set satirlar [split [readfile $::destek_dosyasi] "\n"]
    set yeniliste ""
    set bulundu 0

    foreach satir $satirlar {
        if {[string match "$id|*" $satir]} {
            set parcalar [split $satir "|"]
            set kullanici [lindex $parcalar 1]
            set mesaj [lindex $parcalar 2]
            set yeni "$id|$kullanici|$mesaj|Yanıtlandı"
            set bulundu 1

            # Yanıt kaydı
            set f2 [open $::yanit_dosyasi a]
            puts $f2 "$id|$nick|$yanit"
            close $f2

            # PM gönder
            putquick "PRIVMSG $kullanici :📬 Destek talebinize yanıt geldi ($id): $yanit"
        } else {
            set yeni $satir
        }
        append yeniliste "$yeni\n"
    }

    if {$bulundu} {
        writefile $::destek_dosyasi $yeniliste
        putquick "PRIVMSG $chan :✅ $id ID'li talep yanıtlandı."
    } else {
        putquick "PRIVMSG $chan :❌ $id ID'li talep bulunamadı."
    }
}

proc destek_istatistik {nick uhost handle chan text} {
    if {[lsearch -exact $::adminler $nick] == -1} return

    set acik 0
    set yanitli 0
    set satirlar [split [readfile $::destek_dosyasi] "\n"]

    foreach s $satirlar {
        if {[string match "*|*|*|Açık" $s]} { incr acik }
        if {[string match "*|*|*|Yanıtlandı" $s]} { incr yanitli }
    }

    putquick "PRIVMSG $chan :📊 İstatistik: Açık: $acik | Yanıtlanan: $yanitli | Toplam: [expr {$acik + $yanitli}]"
}

# Yardımcı dosya okuma/yazma
proc readfile {file} {
    if {[file exists $file]} {
        set f [open $file r]
        set d [read -nonewline $f]
        close $f
        return $d
    }
    return ""
}

proc writefile {file data} {
    set f [open $file w]
    puts -nonewline $f $data
    close $f
}
 
Webmasterforumlari.com yorumlarınız değerlidir..