IRCForumu.Net - Türkiye'nin IRC ve mIRC Kullanıcılarının Buluştuğu Forum

IRCForumu.Net - Türkiye'nin IRC ve mIRC Kullanıcılarının Buluştuğu Forum (https://www.ircforumu.net/)
-   TCL Scriptler (https://www.ircforumu.net/tcl-scriptler/)
-   -   Global Mesaj TCL (https://www.ircforumu.net/tcl-scriptler/2871-global-mesaj-tcl.html)

immortaL 02 Temmuz 2016 14:26

Global Mesaj TCL
 
Kod:

#########
# BASLA #
#########

# Global mesaj sistemini acip kapatma komutunun isleyecegi kanali belirtiniz.
set glbmsg(operchan) "#Admin"

# Global komut on ekini belirtiniz.
set glbmsg(komut) ".global"

# Global mesajlarin bulundugu dosya dizinini belirtiniz.
set glbmsg(text) "scripts/globalmsg.txt"

# Global mesajlar kac dakika arayla atilacaksa belirtiniz. (Dakika cinsinden)
set glbmsg(zaman) "5"

######################
# DOKUNMA BOZULUR :d #
######################

proc globalat {} {
global botnick globalat glbmsg
        set msgzaman "0"
        set dosya [open $glbmsg(text) r]
        set liste [split [subst -nocommands [read $dosya]] \n]
        foreach i $liste {
                if {[lrange $i 2 end] != ""} {
                        set msgzaman [expr $msgzaman + $glbmsg(zaman)]
                        timer $msgzaman[list putquick "os global [lrange $i 2 end]"]
                }
        }
        close $dosya
        timer $msgzaman[list globalat]
}

bind evnt - init-server baglan:dosyayarat
proc baglan:dosyayarat {type} {
global botnick glbmsg
        if {![file exists $glbmsg(text)]} {
                set dosya [open $glbmsg(text) w]
                close $dosya
        }
}

set durum "0"

bind pub - $glbmsg(komut) globalonoff
proc globalonoff {nick uhost hand chan text} {
global botnick glbmsg durum
        set komut "[lindex [split $text] 0]"
        set mesaj "[lrange [split $text] 1 end]"
        if {[string match -nocase $glbmsg(operchan) $chan]} {
                if {$komut == ""} {
                        putquick "PRIVMSG $chan :Kullanimi: $glbmsg(komut) \002\002"
                        return 0
                }
                if {[string match -nocase "on" $komut]} {
                        globalat
                        set durum "1"
                        putquick "PRIVMSG $chan :Global mesaj sistemi \002acildi\002."
                        return 0
                }
                if {[string match -nocase "off" $komut]} {
                        killtimer [lindex [timers] [lsearch [timers] "*globalat*"] end]
                        set durum "0"
                        putquick "PRIVMSG $chan :Global mesaj sistemi \002kapatildi\002."
                        return 0
                }
                if {[string match -nocase "durum" $komut]} {
                        if {$durum == "1"} {
                                putquick "PRIVMSG $chan :Global mesaj sistemi \002acik\002."
                        } else {
                                putquick "PRIVMSG $chan :Global mesaj sistemi \002kapali\002."
                                return 0
                        }
                }
                if {[string match -nocase "ekle" $komut]} {
                        if {$mesaj == ""} {
                                putquick "PRIVMSG $chan :Global mesaj belirtmediniz. Lutfen global mesajinizi belirtiniz."
                                return 0
                        }
                        putquick "PRIVMSG $chan :GLOBAL MESAJ: $mesaj » Basariyla global mesaj listesine eklendi."
                        set globs [open $glbmsg(text) a]
                        puts $globs "[join [rand 9999]] [join -] [join $mesaj]"
                        flush $globs
                        catch {closer $globs}
                }
                if {[string match -nocase "sil" $komut]} {
                        if {![file exists $glbmsg(text)]} {
                                putquick "PRIVMSG $chan :Global mesaj listesi zaten bos."
                                return
                        }
                        set data ""
                        set input [open $glbmsg(text) r]
                        while {![eof $input]} {
                                set curline [gets $input]
                                set curline [split $curline]
                                if {$curline != ""} {
                                        set data [linsert $data end $curline]
                                }
                        }
                        catch {close $input}
                        set deger -1
                        set esles ""
                        foreach line $data {
                                incr deger
                                if {[string match -nocase "$mesaj" [lindex $line 0]]} {
                                        set esles $deger
                                        break
                                }
                        }
                        if {$esles == ""} {
                                putquick "PRIVMSG $chan :Boyle bir global mesaj listede yok."
                                putquick "PRIVMSG $chan :Listeyi gormek icin: \002$glbmsg(komut) listele\002"
                                putquick "PRIVMSG $chan :Silmek icin global mesajin basinda ki numarayi kullaniniz. Ornek: \002$glbmsg(komut) sil 1234\002"
                                return
                        }
                        set newdata [lreplace $data $deger $deger]
                        set output [open $glbmsg(text) w]
                        foreach newline $newdata {
                                if {$newline != ""} {
                                        puts $output $newline
                                }
                        }
                        flush $output
                        catch {close $output}
                        putquick "PRIVMSG $chan :\002$mesaj\002 numarali global mesaj listeden silindi."
                        return
                }
                if {[string match -nocase "listele" $komut]} {
                        if {![file exists $glbmsg(text)]} {
                                putquick "PRIVMSG $chan :Global mesaj listesi bos."
                                return 0
                        }
                        set input [open $glbmsg(text) r]
                        set lines [split [subst -nocommands [read $input]] \n]
                        catch {close $input}
                        set sayc 0
                        foreach line $lines {
                                if {$line != ""} {
                                        putquick "PRIVMSG $chan :$line"
                                        incr sayc
                                }
                        }
                        if {$sayc == 0} {
                                putquick "PRIVMSG $chan :Global mesaj listesinde hic kayit bulunamadi."
                                return
                        } else {
                                putquick "PRIVMSG $chan :Global mesaj listesinin sonu..."
                        }
                }
        }
}

#########
# BITTI #
#########



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 22:17.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0
Copyright ©2005 - 2023 IRCForumu.Net - Tüm Hakları Saklıdır.