Giriş

Orijinalini görmek için tıklayınız : !DuyuruEkle & !DuyuruCıkar & !DuyuruListele


No_FeaR
22 Mart 2015, 14:09
#Opers kanalinda global mesaj sistemini yonetme ozelligi ekledim.
Yardimlari icin BuCaLI'ya tsk.

<Namesis> !global
<Ra> Kullanimi: !global <on/off/durum/ekle/sil/listele>

<Namesis> !global on
<Ra> Global mesaj sistemi acildi.

<Namesis> !global durum
<Ra> Global mesaj sistemi acik.

<Namesis> !global off
<Ra> Global mesaj sistemi kapali.

<Namesis> !global ekle
<Ra> Global mesaj belirtmediniz. Lutfen global mesajinizi belirtiniz.

<Namesis> !global ekle Test mesajidir.
<Ra> GLOBAL MESAJ: Test mesajidir. » Basariyla global mesaj listesine eklendi.

<Namesis> !global sil
<Ra> Boyle bir global mesaj listede yok.
<Ra> Listeyi gormek icin: !global listele
<Ra> Silmek icin global mesajin basinda ki numarayi kullaniniz. Ornek: !global sil 1234

<Namesis> !global listele
<Ra> 4790 - Test mesajidir.
<Ra> Global mesaj listesinin sonu...

<Namesis> !global sil 4790
<Ra> 4790 numarali global mesaj listeden silindi.


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

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

# 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) "15"

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

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

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
}
}

setudef flag globcmd

bind pub - $glbmsg(komut) globalonoff
proc globalonoff {nick uhost hand chan text} {
global botnick glbmsg
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<on/off/durum/ekle/sil/listele>\002"; return 0 }
if {[string match -nocase "on" $komut]} { channel set $chan +globcmd; putquick "PRIVMSG $chan :Global mesaj sistemi \002acildi\002."; globalat; return 0 }
if {[string match -nocase "off" $komut]} { channel set $chan -globcmd; putquick "PRIVMSG $chan :Global mesaj sistemi \002kapatildi\002."; return 0 }
if {[string match -nocase "durum" $komut]} { if {[lsearch -exact [channel info $chan] +globcmd] != -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 #
#########