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 TCL ( Süre Aralıkları iLe ) (https://www.ircforumu.net/tcl-scriptler/2629-global-tcl-sure-araliklari-ile.html)

immortaL 29 Haziran 2016 17:58

Global TCL ( Süre Aralıkları iLe )
 
Opers kanalinda global mesaj sistemini yonetme ozelligi ekledim.
Yardimlari icin BuCaLI'ya tsk.

!global
Kullanimi: !global

!global on
Global mesaj sistemi acildi.

!global durum
Global mesaj sistemi acik.

!global off
Global mesaj sistemi kapali.

!global ekle
Global mesaj belirtmediniz. Lutfen global mesajinizi belirtiniz.

!global ekle Test mesajidir.
GLOBAL MESAJ: Test mesajidir. » Basariyla global mesaj listesine eklendi.

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

!global listele
4790 - Test mesajidir.
Global mesaj listesinin sonu...

!global sil 4790
4790 numarali global mesaj listeden silindi.





Kod:

#########
# 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\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 #
#########



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

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.