IRCRehberi.Net- Türkiyenin En iyi IRC ve Genel Forum Sitesi  
 sohbet
seviyeli sohbet


Eggdrop, NeoStats, BNC Sunucu botları, kurulumları ve ayalarına bu başlık altından ulaşabilirsiniz.

🎙️ LAFZONA Sesli ve görüntülü konuşma • İnteraktif yayıncılık • Müzik ve sohbet bir arada Katıl →
 
 
Seçenekler Stil
Alt 07 Ağustos 2026, 01:24   #1
Standart Kelime botu ( Türkçe karakter sorunu çözüldü )

Kod

###########################################################
#         	 https://www.Sohbetlive.com.tr 		  #
###########################################################

#soru bankanizdaki kacinci sorudan soru sormaya baslasin?
set tgquestionnumber "0"

# soru dosyalarının tutlacağı dizin. (Turkish)
set tgqdb "scripts/Kelime/kelime.questions"

# skorların yazılacağı dizin (Turkish)
set tgscf "scripts/Kelime/kelime.scores"

# soru veya cevap hatalarının saklanacağı dizin (Turkish)
set tgerrfil "scripts/Kelime/soru.errors"

# [0/1] Hata raporu mail araciligi ile gonderilsin mi (Turkish)
set tgerrmethod 0

# hata raporu gonderilmeden once gecici dosyalar nerede saklansin (Turkish)
set tgerrmailtmp "/tmp"

# hata raporlarinin gonderilecegi mail adresi (Turkish)
set tgerremail "[email protected]"

# Oyunun oynanacagi kanal (Turkish)
set tgchan "#Kelime"

# doğru cevaba verilecek puan (Turkish)
set tgpointsperanswer[list "10" "20" "30" "40" "50" "100" "150" "200"]

# Soru cevap ayraci girin (Turkish)
set tgqdbsep "|"

# soru bankanizda sorular (Turkish)
# SORU\CEVAP seklinde ise 1 (Turkish)
# CEVAP\soru seklinde ise 0 (Turkish)
set tgqdbquestionfirst 0

# Web sayfasi olarak düzenlenen dosya nerede saklansin. (Turkish)
set tghtmlfile "scripts/mychan.html"

# web sayafsi ne zaman sürede update edilsin (Turkish)
set tghtmlrefresh 0

#  Web sayfasi kaydedilirken kullanilacak fontlar. (Turkish)
set tghtmlfont "verdana,helvetica,arial"

# En fazla verilecek ipucu sayısı (Turkish)
set tgmaxhint 3

#  ipucu gosterilsin mi (1) evet (0) hayir? (Turkish)
set tgalwaysshowq 1

#  Sorular Buyuk harfle yazilsin mi(1)evet (0) hayir?
set tgcapsquestion 0

#  Cevaplar büyük harfle yazilsin mi(1) evet (0) hayir?
#  Show answers in all CAPS (1) or not (0)?
set tgcapsanswer 0

#  ipuclari buyuk harfle yazilsinmi (1)evet (0) hayir?
#  Show hints in all CAPS (1) or not (0)?
set tgcapshint 0

# en az kaç soru üst üste bilindiğinde cevap serisi yakaladı olarak kayıt edilecek
#  The minimum number of correct answers in a row by one person which
#  puts them on a winning streak. Setting this to 0 will disable the
#  winning streak feature.
set tgstreakmin 5

#belirli sayıda soru bilinmezse oyun kapatılacak. !skip komutu hadil değil. 0 disable yapar.
#  The number of missed (i.e. unanswered, not skipped) questions to allow
#  before automatically stopping the game. Setting this to 0 will cause the
#  game to run until somebody uses the stop command, or the bot dies, gets
#  killed, pings out, or whatever.
set tgmaxmissed 0

# ipucu karakteri
#  The character to use as a placeholder in hints.
set tghintchar "*"

#verilen ipucları arasındaki süre. saniye cinsinden.
#  The time in seconds between hints.
set tgtimehint 8

#bir sonraki soruyu sorma süresi. saniye cinsinden.
#  The time in seconds between a correct answer, 'expired' or skipped question
#  and the next question being asked.
set tgtimenext 5

#tebrik mesajları
#  Phrases to use at random when someone answers a question correctly. This must
#  be a TCL list. If you don't know what that means, stick to the defaults.
set tgcongrats[list "Harikasin" "Bravo bildin" "Iyi hareket" "Tebrikler" "Iste oyun bu" "Guzel gidiyorsun" "Oyun nasil oynanir goster" "Bravo"]

#doğru cevap verilemediğinde gösterilecek mesajlar.
#  Phrases to use when the question has 'expired'. Must also be a TCL list.
set tgnobodygotit[list "Dogru cevabi bilen cikmadi." "Evde kimse varmi?" "Cevap yok!" "Bu sorular cokmu zor geldi?" "Acaba burda yalniz miyim?" "Boyle giderse kimse balon alamayacak!" "Canlanin biraz"]

#bir sonraki soru bildirim mesajı
#  Phrases to use when the question expired and there's another one coming up.
#  Yep, you guessed it... another TCL list.
set tgtrythenextone[list "Bakalim sonrakini bilecekmisiniz..." "Bir sonraki icin hazirlanin..." "Belki bir sonrakini bilirsiniz..." "Bakalim bunu bulabilecekmisiniz..." "Sonraki soru geliyor..."]

#  Will the bot calculate the time it took to get the correct
#  answer (1) or not (0)? (requires TCL 8.3 or higher).
set tgtimeanswer 1

#  Sorunun Cevabi gosterilsin mi? (1) evet (0) hayir?
#  Will the bot show the correct answer if nobody gets it (1) or not (0)?
set tgshowanswer 1

# Sorulan sorular her bilindiginde skor tablosu gosterilsin mi ?
#  When someone answers a question, will the bot show just that person's score (0)
#  or will it show all players' scores (1) (default). This is useful in channels with
#  a large number (>20) players.
set tgshowallscores 0

#bold mesaj kullanımı açık/kapalı ayarı. 0 kapalı için
#  Use bold codes in messages (1) or not (0)?
set tgusebold 0

# Mesaj sistemi ne olarak kullanilsin /msg ise 1 /notice ise 0
#  Send private messages using /msg (1) or not (0)?
#  If set to 0, private messages will be sent using /notice
set tgpriv2msg 1

#yardım komutu
#  Word to use as /msg command to give help.
#  e.g. set tgcmdhelp "helpme" will make the bot give help when someone
#  does "/msg <botnick> helpme"
set tgcmdhelp "help"

#oyun başlatma komutu
#  Channel command used to start the game.
set tgcmdstart "!basla"

#oyunu kimlerin başlatabileceğini belirleyen bayrak(flag) ayarları. sadece bota kayıtlı oplar için o|o yazın.
#bütün kullanıcılar için -|- yazın. 

#  Flags required to be able to use the start command.
set tgflagsstart "-|-"

#oyunu durdurma komutu
#  Channel command used to stop the game.
set tgcmdstop "!dur"

#oyunu kimlerin durdurabileceğini belirleyen bayrak(flag) ayarları. sadece bota kayıtlı oplar için o|o yazın. 
#bütün kullanıcılar için -|- yazın. 
#  Flags required to be able to use the stop command.
set tgflagsstop "-|-"

# ipucu komutu
#  Channel command used to give a hint.
set tgcmdhint "ipucu"

#oyunuda kimlerin ipucu komutunu kullanabileceğini belirleyen bayrak(flag) ayarları.
# sadece bota kayıtlı oplar için o|o yazın.  bütün kullanıcılar için -|- yazın. 
#  Flags required to be able to use the hint command.
set tgflagshint "-|-"

#  Disable the !hint command x seconds after someone uses it. This
#  prevents accidental double hints if two people use the command in
#  quick succession.
set tgtempnohint 3

#soru atlatma komutu
# Channel command used to skip the question.
set tgcmdskip "!gec"

#oyunuda kimlerin !skip komutunu kullanabileceğini belirleyen bayrak(flag) ayarları.
# sadece bota kayıtlı oplar için o|o yazın.  bütün kullanıcılar için -|- yazın.
#  Flags required to be able to use the skip command.
set tgflagsskip "-|-"

#  top10 komudu.
#  Channel command for showing the top 10 scores.
#  Flags required to use the top 10 command.
set tgcmdtop10 "!top10"

#oyunuda kimlerin !top10 komutunu kullanabileceğini belirleyen bayrak(flag) ayarları.
# sadece bota kayıtlı oplar için o|o yazın.  bütün kullanıcılar için -|- yazın.
set tgflagstop10 "-|-"

# skor temizleme komutu
#  /msg command used to reset scores.
set tgcmdreset "temizle"

#oyunuda kimlerin temizle komutunu kullanabileceğini belirleyen bayrak(flag) ayarları.
# sadece bota kayıtlı oplar için o|o yazın.  bot yöneticileri için n|n yazın.
#  Flags required to be able to use the reset command.
set tgflagsreset "n|n"

#skor tablosunu sifirlamak icin bota login oldugunu sifreyi kullanin
#  Require password for resetting scores?
#  If enabled, you must use /msg bot reset <password> to reset scores.
#  The password is the one set by a user using '/msg bot pass'.
set tgresetreqpw 1

#  /msg command for looking up somebody's score.
#skor öğrenme komutu
set tgcmdlookup "skor"

#başkasının skorunu öğrenme komutu
#  /msg command for looking up your target.
#  (i.e. the person ranked one higher than you).
set tgcmdtarget "hedef"

#hata bildirme komutu
#  /msg command for reporting errors in questions and/or answers.
set tgcmderror "hata"

#  kurallar komudu.
#  /msg command to show channel's rules.
set tgcmdrules "kural"

#  ay birincileri komudu.
#  Channel command to show last month's winners.
set tgcmdlastwinners "!aybirincileri"
set tgflagslastwinners "-|-"

#  Kanal kuralları.
#  Channel's rules.
set tgrules "Reklam, Tekrar, Flood, Küfür ve bezeri tutumsuz hareketlerde bulunmak yasaktir. Iyi Sanslar. :-)"

#  COLOURS
#  The colour codes used are the same as those used by mIRC:
#  00:white        01:black        02:dark blue    03:dark green
#  04:red          05:brown        06:purple       07:orange
#  08:yellow       09:light green  10:turquoise    11:cyan
#  12:light blue   13:magenta      14:dark grey    15:light grey
#
#  Always specify colour codes as two digits, i.e. use "01" for
#  black, not "1".
#  You can specify a background colour using "00,04" (white text
#  on red background).
#  To disable a colour, use "".
#  Note that disabling some colours but not others may yield
#  unexpected results.

set tgcolourstart "03"		;#Game has started.
set tgcolourstop "04"		;#Game has stopped.
set tgcolourskip "10"		;#Question has been skipped.
set tgcolourerr "04"		;#How to report errors.
set tgcolourmiss "10"		;#Nobody answered the question.
set tgcolourqhead "04"		;#Question heading.
set tgcolourqbody "0,6"	;#Question text
set tgcolourhint "0,6"	;#Hint.
set tgcolourstrk "12"		;#Person is on a winning streak.
set tgcolourscr1 "04"		;#Score of person in first place.
set tgcolourscr2 "12"		;#Score of person in second place.
set tgcolourscr3 "03"		;#Score of person in third place.
set tgcolourrset "04"		;#Scores have been reset.
set tgcolourstend "12"		;#Winning streak ended.
set tgcolourmisc1 "06"		;#Miscellaneous colour #1.
set tgcolourmisc2 "04"		;#Miscellaneous colour #2.
set tgcolantihack "06"		;#Bosluk yerine gelecek olan harfler hangi renklerle gizlensin


proc tg_norm {t} {
    # Renk kodlarini temizle
    regsub -all {([0-9]{1,2}(,[0-9]{1,2})?)?} $t "" t

    # Buyuk harfli Turkce karakterleri kucuk harfli Turkce karakterlere cevir
    set t [string map {
        Ç ç
        Ğ ğ
        İ i
        I ı
        Ö ö
        Ş ş
        Ü ü
    } $t]

    # tolower
    set t [string tolower $t]

    # Kucuk harfli Turkce karakterleri ASCII'ye cevir
    set t [string map {
        ç c
        ğ g
        ı i
        ö o
        ş s
        ü u
    } $t]

    # Sadece a-z0-9 birak
    regsub -all {[^a-z0-9]+} $t "" t

    return $t
}

#Misc checks & var initialisations
set tgver "1.3.4"
set tgrel "release"
if {[info tclversion]<8.2} {
	putlog "\002[file tail [info script]]\002 failed to load: in order to use this script, eggdrop needs to be compiled to use tcl 8.2 or higher (recommended: latest stable version)."
	return
}
if {$tgtimeanswer==1&&[info tclversion]<8.3} {
	putlog "\002[file tail [info script]]\002 warning: timing of answers has been automatically disabled. this feature requires tcl 8.3 or higher."
	set tgtimeanswer 0
}
if {![info exists alltools_loaded]||$allt_version<205} {
	putlog "\002[file tail [info script]]\002 failed to load: please load alltools.tcl v1.14 or higher (available with eggdrop 1.6.13 or higher) before attempting to load this script."
	return
}
if {[utimerexists tghtml]!=""} {killutimer $tghtmlrefreshtimer}
if {$tghtmlrefresh>0} {
	set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}
if {![file exists $tgqdb]} {
	putlog "\002[file tail [info script]]\002 failed to load: $tgqdb does not exist."
	return
}
if {[llength [split $tgchan]]!=1} {
	putlog "\002[file tail [info script]]\002 failed to load: too many channels specified."
	return
}
if {![info exists tgplaying]} {
	set ctcp-version "${ctcp-version} SysteMReloaded is a System Coder !"
	set tgplaying 0
}
if {![info exists tghintnum]} {set tghintnum 0}
if {![info exists tgmissed]} {set tgmissed 0}

# Ay başı sıfırlama timer'ını başlat
if {[info exists tgmonthlyreset] && $tgmonthlyreset} {
    timer 60 tgcheckmonthlyreset
}

# Otomatik topic timer'ını başlat (2 saatte bir)
if {[info exists tgautotopic] && $tgautotopic} {
    set tgtopictimer [timer 7200 tgupdatetopic]
}

#Binds
bind pubm $tgflagsstart "$tgchan %$tgcmdstart" tgstart
bind pubm $tgflagsstop "$tgchan %$tgcmdstop" tgstop
proc tgbindhintcmd {} {
	global tgflagshint tgcmdhint
	bind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
proc tgunbindhintcmd {} {
	global tgflagshint tgcmdhint
	unbind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
tgbindhintcmd
bind pubm $tgflagsskip "$tgchan %$tgcmdskip" tgskip
bind pubm $tgflagstop10 "$tgchan %$tgcmdtop10" tgshowtop10
bind join -|- "$tgchan *" tgjoinmsg
bind msg - $tgcmdhelp tggivehelp
bind msg - $tgcmdlookup tgscorelookup
bind msg - $tgcmdtarget tgtargetlookup
bind msg - $tgcmderror tgerror
bind msg - $tgcmdrules tgrulesmsg
bind msg $tgflagsreset "$tgcmdreset" tgresetscores
bind kick - "$tgchan $botnick" tgbotgotkicked
bind evnt - disconnect-server tgbotgotdisconnected

# YENİ BIND'LER
bind pubm $tgflagslastwinners "$tgchan %$tgcmdlastwinners" tgshowlastwinners

#starts the game if it isn't running.
proc tgstart {nick host hand chan text} {
	global tgplaying tgstreak tgchan tgerrremindtime tgerrremindtimer tgmissed
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==0} {
			tggamemsg "[tgcolstart]Oyun \002$nick\002 tarafından başlatıldı!"
			tgnextq
			set tgplaying 1
			set tgstreak 0
			set tgmissed 0
			set tgerrremindtimer [timer 15 tgerrremind]
		}
	}
}

#stops the game if it's running.
proc tgstop {nick host hand chan text} {
	global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
	global tgerrremindtimer tgrebindhinttimer
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==1} {
			tggamemsg "[tgcolstop]Oyun \002$nick\002 tarafından durduruldu!"
			if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
			set tgstreak 0
			set tgplaying 0
			catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
			if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
			if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
			if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
			if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
		}
	}
}

#gives a hint if there is currently a question to answer.
proc tgforcehint {nick host hand chan text} {
	global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
	global tgtempnohint tgmaxhintcurrent tghintnum tgrebindhinttimer tgtempnohint
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==1&&[utimerexists tghint]!=""} {
			killutimer $tghinttimer
			tghint
			tgunbindhintcmd
			if {$tghintnum<$tgmaxhintcurrent} {
				set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
			}
		}
	}
}

#skips the current question if one has been asked.
proc tgskip {nick host hand chan text} {
	global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak
	global tgstreakmin tgtimenext tgrebindhinttimer
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==1&&[utimerexists tghint]!=""} {
			tggamemsg "[tgcolskip]Soru [tgcolmisc2]$nick'in[tgcolskip] isteği üzerine geçildi..."
			# Streak kontrolu - tg_norm ile
			set _streak_nick [lindex [split $tgstreak ,] 0]
			set _streak_count [lindex [split $tgstreak ,] 1]
			if {$tgstreakmin>0&&$_streak_count>=$tgstreakmin&&[tg_norm $_streak_nick] eq [tg_norm $nick]} {
				tgstreakend
				set tgstreak 0
			}
			catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
			killutimer $tghinttimer
			if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
			set tgnextqtimer [utimer $tgtimenext tgnextq]
		}
	}
}


#bot got kicked. stop the game.
proc tgbotgotkicked {nick host hand chan targ text} {
	tgquietstop
}

#bot got disconnected. stop the game.
proc tgbotgotdisconnected {disconnect-server} {
	tgquietstop
}

#stops the game without telling the channel.
proc tgquietstop {} {
	global tgplaying tgstreak tgchan tgcurrentanswer tghinttimer tgnextqtimer tgerrremindtimer
	global tgrebindhinttimer tgtopictimer
	if {$tgplaying==1} {
		set tgstreak 0
		set tgplaying 0
		catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
		if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
		if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
		if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
		if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
		if {[info exists tgtopictimer] && [timerexists tgupdatetopic]!=""} {killtimer $tgtopictimer}
	}
}

#reads the question database.
proc tgreadqdb {} {
	global tgqdb tgquestionstotal tgquestionslist
	set tgquestionstotal 0
	set tgquestionslist ""
	set qfile [open $tgqdb r]
	set tgquestionslist [split [read -nonewline $qfile] "\n"]
	set tgquestionstotal [llength $tgquestionslist]
	close $qfile
}

#selects the next question.
proc tgnextq {} {
	global tgqdb tgcurrentquestion tgcurrentanswer tgquestionnumber
	global tgquestionstotal tghintnum tgchan tgquestionslist tgqdbsep tgqdbquestionfirst
	global tgcapsquestion tgcapsanswer
	tgreadqdb
	set tgcurrentquestion ""
	set tgcurrentanswer ""
	while {$tgcurrentquestion == ""} {
            set tgquestionnumber [rand [llength $tgquestionslist]]
		set tgquestionselected [lindex $tgquestionslist $tgquestionnumber]
		set tgcurrentquestion [lindex [split $tgquestionselected $tgqdbsep] [expr $tgqdbquestionfirst^1]]
		if {$tgcapsquestion==1} {
			set tgcurrentquestion [strupr $tgcurrentquestion]
		}
		set tgcurrentanswer [string trim [lindex [split $tgquestionselected $tgqdbsep] $tgqdbquestionfirst]]
		if {$tgcapsanswer==1} {
			set tgcurrentanswer [strupr $tgcurrentanswer]
		}
	}
	unset tghintnum
	tghint
	bind pubm -|- "$tgchan *" tgcheckanswer
	return
}

#shows timed hints.
proc tghint {} {
	global tgmaxhint tghintnum tgcurrentanswer tghinttimer tgchan
	global tgtimehint tghintchar tgquestionnumber tgquestionstotal
	global tgcurrentquestion tghintcharsused tgnextqtimer tgtimenext tgstreak tgstreakmin
	global tgnobodygotit tgtrythenextone tgmissed tgmaxmissed tgcmdstart tgshowanswer
	global tgtimestart tgtimeanswer tgalwaysshowq tgmaxhintcurrent tgtempnohint tgcapshint
if {![info exists tghintnum]} {
                set tghintnum 0
regsub -all {ğ} $tgcurrentanswer "g" tgcurrentanswer
regsub -all {Ğ} $tgcurrentanswer "G" tgcurrentanswer
regsub -all {ü} $tgcurrentanswer "u" tgcurrentanswer
regsub -all {Ü} $tgcurrentanswer "U" tgcurrentanswer
regsub -all {ş} $tgcurrentanswer "s" tgcurrentanswer
regsub -all {Ş} $tgcurrentanswer "S" tgcurrentanswer
regsub -all {ı} $tgcurrentanswer "i" tgcurrentanswer
regsub -all {İ} $tgcurrentanswer "I" tgcurrentanswer
regsub -all {ö} $tgcurrentanswer "o" tgcurrentanswer
regsub -all {Ö} $tgcurrentanswer "O" tgcurrentanswer
regsub -all {ç} $tgcurrentanswer "c" tgcurrentanswer
regsub -all {Ç} $tgcurrentanswer "C" tgcurrentanswer
regsub -all -- "\[^A-Za-z0-9\]" $tgcurrentanswer "" _hintchars
                set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
                catch {tgunbindhintcmd}
                if {$tgmaxhintcurrent>0} {
         set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
      }
   } else { incr tghintnum }
	if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
		incr tgmissed
		set _msg ""
		append _msg "[tgcolmiss][lindex $tgnobodygotit [rand [llength $tgnobodygotit]]]"
		if {$tgshowanswer==1} {
			append _msg " Cevap [tgcolmisc2]$tgcurrentanswer[tgcolmiss]."
		}
		if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} {
			append _msg " $tgmissed soru sordum ve cevap alamadim ve oyunu durduruyorum. Yeniden baslatmak için $tgcmdstart yazmalısınız."
			tgquietstop
		} else {
			append _msg " [lindex $tgtrythenextone [rand [llength $tgtrythenextone]]]"
		}
		tggamemsg "[tgcolmiss]$_msg"
		if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
		set tgstreak 0
		catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
		if {$tgmaxmissed==0||$tgmissed<$tgmaxmissed} {
			set tgnextqtimer [utimer $tgtimenext tgnextq]
		}
		return
	} elseif {$tghintnum == 0} {
		set i 0
		set _hint {}
		set tghintcharsused {}
		foreach word [split $tgcurrentanswer] {
			regsub -all -- "\[A-Za-z0-9\]" $word $tghintchar _current
			lappend _hint $_current
		}
		if {$tgtimeanswer==1} {
			set tgtimestart [clock clicks -milliseconds]
		}
	} elseif {$tghintnum == 1} {
		set i 0
		set _hint {}
		while {$i<[llength [split $tgcurrentanswer]]} {
			set _word [lindex [split $tgcurrentanswer] $i]
			set j 0
			set _newword {}
			while {$j<[strlen $_word]} {
				if {$j==0} {
					append _newword [stridx $_word $j]
					lappend tghintcharsused $i,$j
				} else {
					if {[string is alnum [stridx $_word $j]]} {
						append _newword $tghintchar
					} else {
						append _newword [stridx $_word $j]
						lappend tghintcharsused $i,$j
					}
				}
				incr j
			}
			lappend _hint $_newword
			incr i
		}
		} else {
			set i 0
			set _hint {}
			while {$i<[llength [split $tgcurrentanswer]]} {
				set _word [lindex [split $tgcurrentanswer] $i]
				set j 0
				set _newword {}
				set _selected [rand [strlen $_word]]
				regsub -all -- "\[^A-Za-z0-9\]" $_word "" _wordalnum
				if {[strlen $_wordalnum]>=$tghintnum} {
					while {[lsearch $tghintcharsused $i,$_selected]!=-1||[string is alnum [stridx $_word $_selected]]==0} {
					 set _selected [rand [strlen $_word]]
					}
				}
				lappend tghintcharsused $i,$_selected
				while {$j<[strlen $_word]} {
					if {[lsearch $tghintcharsused $i,$j]!=-1||[string is alnum [stridx $_word $j]]==0} {
						append _newword [stridx $_word $j]
					} else {
						if {[string is alnum [stridx $_word $j]]} {
							append _newword $tghintchar
						}
				}
				incr j
			}
			lappend _hint $_newword
			incr i
		}
	}
	if {$tgcapshint==1} {
		set _hint [strupr $_hint]
	}
      if {$tghintnum==0} {

            regsub -all {\s} $tgcurrentquestion [tgantihack][randstring 1 abcdefghijklmnopqrstuvwxyz][tgcolqbody] tgcurrentquestion
		
		tggamemsg "[merlin][tgcolqbody]$tgcurrentquestion"
	}
      if {$tghintnum>0} {
	      tggamemsg "[tgcolhint]Ipucu: [join $_hint]"
      }
	set tghinttimer [utimer $tgtimehint tghint]
}


#triggered when someone uses !top10 command
proc tgshowtop10 {nick host hand chan text} {
	global tgscores tgchan tgscorestotal
	if {[strlwr $chan]==[strlwr $tgchan]} {
		tggetscores
		if {$tgscorestotal>0} {
			if {$tgscorestotal>9} {
				set _max 9
			} else {
				set _max [expr $tgscorestotal-1]
			}
			set i 0
			while {$i<=$_max} {
				set _item [lindex $tgscores $i]
				set _nick [join [lindex [split $_item ,] 2]]
				set _score [join [lindex [split $_item ,] 0]]
				if {$i==0} {
					append _scores "[tgcolscr1]$_nick $_score"
				} elseif {$i==1} {
					append _scores ", [tgcolscr2]$_nick $_score"
				} elseif {$i==2} {
					append _scores ", [tgcolscr3]$_nick $_score"
				} else {
					append _scores ", [tgcolmisc1]$_nick $_score"
				}
				incr i
			}
			tggamemsg "[tgcolmisc1]Top 10: $_scores"
		} else {
			tggamemsg "[tgcolmisc1]Skor tablosu boş."
		}
	}
}
proc tgerrremndersiscos {} {
 set string "Bol Şanslar Dileriz.."
 regsub -all {%20} $string {} output
 tggamemsg "\2$output"
}
#checks if anyone has said the correct answer on channel.
proc tgcheckanswer {nick host hand chan text} {
	global tgcurrentanswer
	# tg_norm kullanarak cevap kontrolu - Turkce karakter destegi
	if {[tg_norm $tgcurrentanswer] eq [tg_norm [tgstripcodes [string trim $text]]]} {
		tgcorrectanswer $nick
	}
}

#triggered when someone says the correct answer.
proc tgcorrectanswer {nick} {
	global tgcurrentanswer tghinttimer tgtimenext tgchan tgnextqtimer tgstreak tgstreakmin
	global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed
	global tgtimestart tgshowallscores tgrealnames tgscoresbyrank tgtimeanswer tgscores tgpointsperanswer
	tggetscores
	# tg_norm kullanarak nick anahtari olustur
	set _nick_key [tg_norm $nick]
	if {![info exists tgranksbyname($_nick_key)]} {
		set _oldrank 0
	} else {
		set _oldrank $tgranksbyname($_nick_key)
	}
      set puan [lindex $tgpointsperanswer [rand [llength $tgpointsperanswer]]]
	tgincrscore $nick $puan
	tggetscores
	set _newrank $tgranksbyname($_nick_key)
	set _timetoanswer ""
	if {$tgtimeanswer==1} {
		set _timetoanswer [expr [expr [clock clicks -milliseconds]-$tgtimestart]/1000.00]
	}
	set _msg "[tgcolmisc1][lindex $tgcongrats [rand [llength $tgcongrats]]] [tgcolmisc2]$nick[tgcolmisc1]! Doğru Cevap [tgcolmisc2]$tgcurrentanswer[tgcolmisc1].[expr $tgtimeanswer==1?" Soruyu [tgcolmisc2]$_timetoanswer[tgcolmisc1] Saniyede Bildiniz.":""]"
	set _msg2 "[tgcolmisc2]$nick [tgcolstrk]'$tgcurrentanswer'[tgcolmisc1] Size [tgcolmisc2]$puan[tgcolmisc1] Balon kazandırdı!"


	if {$_newrank<$_oldrank} {
		if {$_newrank==1} {
			append _msg " Şu an birincisiniz!"
		} else {
			if {$tgshowallscores==0} {
				append _msg " Seviyeniz yükseldi.!"
			} else {
				append _msg " [tgcolmisc2]$tgscorestotal[tgcolmisc1] kişi içinde [tgcolmisc2]$_newrank. sıradasınız. [tgcolmisc2]$tgrealnames($tgranksbynum([expr $_newrank-1]))[tgcolmisc1]  [tgcolmisc2]$tgscoresbyrank([expr $_newrank-1])[tgcolmisc1] balonla hemen önünüzde."

			}
		}
	}
	tggamemsg "$_msg"
      tggamemsg "$_msg2"
	if {[isop $nick $tgchan]==0 && [ishalfop $nick $tgchan]==0 && [isvoice $nick $tgchan]==0 && $_newrank!=1} {
		set i 0 
		while {$i<[llength $tgscores]} { 
			set _item [lindex $tgscores $i] 
			set _nick [lindex [split $_item ,] 2] 
			set _score [lindex [split $_item ,] 0] 
			# tg_norm ile nick karsilastirmasi
			if {$i<=9&&[tg_norm $nick] eq [tg_norm $_nick]&&[botisop $tgchan]} { 
				tggamemsg "[tgcolmisc1]En çok baloncuk toplayanlar arasına girdin, ödülün [tgcolmisc2]+v(voice)[tgcolmisc1] :)"
				putserv "MODE $tgchan +v $nick" 
			} 
		incr i 
		} 
	}

	if {[botisop $tgchan] && [isop $nick $tgchan]==0 && [ishalfop $nick $tgchan]==0 && [isvoice $nick $tgchan]==0 && $_newrank==1} {
		tggamemsg "[tgcolmisc2]$nick[tgcolmisc1] Oyun 1.si konumundasınız ödülün +v(voice)"
		putserv "MODE $tgchan +v $nick"
	}

	# Streak kontrolu - tg_norm ile
	set _streak_nick [lindex [split $tgstreak ,] 0]
	set _streak_count [lindex [split $tgstreak ,] 1]
	if {$tgstreak!=0} {
		if {[tg_norm $_streak_nick] eq [tg_norm $nick]} {
			set tgstreak [tg_norm $nick],[expr $_streak_count+1]
			if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} {
				tggamemsg "[tgcolmisc2]$nick[tgcolstrk] Cevap serisi yakaladı!! [tgcolmisc2][lindex [split $tgstreak ,] 1] [tgcolstrk]tane soruyu ust uste bildi! Bu size [tgcolmisc2]+100[tgcolmisc1] baloncuk kazandırdı"
                        tgincrscore $nick 100
				if {[botisop $tgchan] && [isop $nick $tgchan]==0 && [ishalfop $nick $tgchan]==0 && [isvoice $nick $tgchan]==0} {
					putserv "MODE $tgchan +v $nick"
				}


			}
		} else {
			if {$tgstreakmin>0&&$_streak_count>=$tgstreakmin} { tgstreakend }
			set tgstreak [tg_norm $nick],1
		}
	} else {
		set tgstreak [tg_norm $nick],1
	}
	set tgmissed 0
	tgshowscores $nick

	# Topic 2 saatte bir otomatik güncellenir (anlık değil)

	catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
	killutimer $tghinttimer
	set tgnextqtimer [utimer $tgtimenext tgnextq]
}

#read current scores from file, sort and store in variable.
proc tggetscores {} {
	global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum
	global tgrealnames tgscoresbyrank
	if {[file exists $tgscf]&&[file size $tgscf]>2} {
		set _sfile [open $tgscf r]
		set tgscores [lsort -dict -decreasing [split [gets $_sfile]]]
		close $_sfile
		set tgscorestotal [llength $tgscores]
	} else {
		set tgscores ""
		set tgscorestotal 0
	}
	if {[info exists tgscoresbyname]} {unset tgscoresbyname}
	if {[info exists tgranksbyname]} {unset tgranksbyname}
	if {[info exists tgrealnames]} {unset tgrealnames}
	if {[info exists tgranksbynum]} {unset tgranksbynum}
	set i 0
	while {$i<[llength $tgscores]} {
		set _item [lindex $tgscores $i]
		set _nick [lindex [split $_item ,] 2]
		set _lwrnick [lindex [split $_item ,] 3]
		set _score [lindex [split $_item ,] 0]
		# tg_norm ile guvenli nick anahtari olustur
		set _safe_nick [tg_norm $_nick]
		set tgscoresbyname($_safe_nick) $_score
		set tgrealnames($_safe_nick) $_nick
		set tgranksbyname($_safe_nick) [expr $i+1]
		set tgranksbynum([expr $i+1]) $_safe_nick
		set tgscoresbyrank([expr $i+1]) $_score
		incr i
	}
	return
}

#increment someone's score.
proc tgincrscore {who bonuspuan} {
	global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname
	tggetscores
	set _who_safe [tg_norm $who]
	if {$tgscorestotal>0} {
		set i 0
		if {![info exists tgscoresbyname($_who_safe)]} {
			append _newscores "$bonuspuan,[expr 1000000000000.0/[unixtime]],$who,$_who_safe "
		}
		while {$i<[llength $tgscores]} {
			set _item [lindex $tgscores $i]
			set _nick [lindex [split $_item ,] 2]
			set _time [lindex [split $_item ,] 1]
			set _score [lindex [split $_item ,] 0]
			# tg_norm ile nick karsilastirmasi
			if {[tg_norm $who] eq [tg_norm $_nick]} {
				append _newscores "[expr $_score+$bonuspuan],[expr 1000000000000.0/[unixtime]],$who,$_who_safe[expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
			} else {
				append _newscores "$_score,$_time,$_nick,[tg_norm $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
			}
			incr i
		}
	} else {
		append _newscores "$bonuspuan,[expr 1000000000000.0/[unixtime]],$who,$_who_safe"
	}
	set _sfile [open $tgscf w]
	puts $_sfile "$_newscores"
	close $_sfile
	return
}

#shows the current scores on channel.
proc tgshowscores {nick} {
	global tgscores tgchan tgscorestotal tgshowallscores tgranksbyname tgranksbynum
	global tgscoresbyname tgrealnames tgscoresbyrank
	tggetscores
	set i 0
	set _nick_safe [tg_norm $nick]
	if {$tgshowallscores} {
		while {$i<[llength $tgscores]} {
			set _item [lindex $tgscores $i]
			set _nick [lindex [split $_item ,] 2]
			set _score [lindex [split $_item ,] 0]
			if {$i==0} {
				append _scores "[tgcolscr1]$_nick $_score"
			} elseif {$i==1} {
				append _scores ", [tgcolscr2]$_nick $_score"
			} elseif {$i==2} {
				append _scores ", [tgcolscr3]$_nick $_score"
			} elseif {[onchan $_nick $tgchan]} {
				append _scores ", [tgcolmisc1]$_nick $_score"
			}
			incr i
		}
		tggamemsg "[tgcolmisc1]Skorlar: $_scores"
	} else {
		if {$tgranksbyname($_nick_safe)==1} {
			set _tgt "."
		} else {
			set _tgt ", hemen onunuzdeki yarismaci [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname($_nick_safe)-1])) [tgcolmisc2]$tgscoresbyrank([expr $tgranksbyname($_nick_safe)-1])[tgcolmisc1] [tgcolmisc1]balona Sahip"
		}
		tggamemsg "[tgcolmisc2]$nick [tgcolmisc1]şu anda [tgcolmisc2]$tgscoresbyname($_nick_safe)[tgcolmisc1] Balona sahipsiniz ve [tgcolmisc2]$tgscorestotal[tgcolmisc1] kişi arasında [tgcolmisc2]$tgranksbyname($_nick_safe).[tgcolmisc1] siniz $_tgt"
	}
}

#reset current scores.
proc tgresetscores {nick host hand text} {
	global tgscf tgscorestotal tgscores tgplaying tgresetreqpw
	if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
		if {[file exists $tgscf]&&[file size $tgscf]>2} {
			set _sfile [open $tgscf w]
			puts $_sfile ""
			close $_sfile
			set tgscores ""
			set tgscorestotal 0
		}
		tggamemsg "[tgcolrset]===== Skor tablosu \002$nick\002 tarafından silindi! ====="
		# Skor sıfırlandığında topic'i güncelle
		tgupdatetopic
	}
}

#triggered when a winning streak ends.
proc tgstreakend {} {
		global tgstreak tgrealnames
		set _streak_nick_safe [lindex [split $tgstreak ,] 0]
		if {[info exists tgrealnames($_streak_nick_safe)]} {
			set _real_nick $tgrealnames($_streak_nick_safe)
		} else {
			set _real_nick $_streak_nick_safe
		}
		tggamemsg "[tgcolstend]İyi gidiyordun [tgcolmisc2]$_real_nick[tgcolstend] iyi bir cevap serisi yakalamisti"
		return
}

#triggered when someone joins trivia chan.
proc tgjoinmsg {nick host hand chan} { 
     global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan 
     global tgscorelookupjoin tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames 
     global tgscoresbyrank tgscores 
     tggetscores 

     if {$nick != $botnick} { 
         # ÖNCELİKLE: Geçen ayın kazananı mı kontrol et (özel karşılama)
         tgcheckprizewinner $nick

         set _msg "" 
         if {$tgplaying==1} { 
             append _msg "Oyun devam ediyor! Katılmak için doğru cevabı yazmanız yeterli. "
         } else { 
             append _msg "Oyun şu an durdurulmuş. Başlatmak için !basla yazın. "
         } 
         if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} { 
             append _msg "Siz de oyunu başlatabilirsiniz!"
         } 
         [tgpriv] $nick "$_msg"

         set _nick_safe [tg_norm $nick]
         if {![info exists tgscoresbyname($_nick_safe)]} { 
             [tgpriv] $nick "Hoş geldiniz! İlk defa oynuyorsunuz. Bol şanslar!"
         } else {
             set _durumu $tgranksbyname($_nick_safe)
             if {$_durumu==1} { 
                 [tgpriv] $nick "Hoş geldiniz! Şu anda 1. sıradasınız. $tgscoresbyname($_nick_safe) balonunuz var!"
             } elseif {$_durumu>1} {
                 set _onceki $tgranksbynum([expr $_durumu-1])
                 set _onceki_puan $tgscoresbyrank([expr $_durumu-1])
                 set _onceki_nick $tgrealnames($_onceki)
                 [tgpriv] $nick "Hoş geldiniz! $_durumu. sıradasınız ($tgscoresbyname($_nick_safe) balon). Hemen önünüzde $_onceki_nick var ($_onceki_puan balon)."
             } 
         } 
     } 
}

#triggered when someone /msgs the bot with the score lookup command.
proc tgscorelookup {nick host hand text} {
	global tgscoresbyname tgranksbyname tgscorestotal tgrealnames
	if {$text==""} { set text $nick } else { set text [lindex [split $text] 0] }
	tggetscores
	set _text_safe [tg_norm $text]
	set _nick_safe [tg_norm $nick]
	if {![info exists tgscoresbyname($_text_safe)]} {
		if {[tg_norm $text] eq [tg_norm $nick]} {
			set _who "[tgcolmisc1]Nickinizin"
		} else {
			set _who "[tgcolmisc2]$text [tgcolmisc1]"
		}
		[tgpriv] $nick "[tgbold]$_who [tgcolmisc1]skor tablosunda yok."
	} else {
		set _siralama $tgranksbyname($_text_safe)
		if {[tg_norm $text] eq [tg_norm $nick]} {
			set _who "[tgcolmisc1]Nickinizin"
		} else {
			set _who "[tgcolmisc2]$tgrealnames($_text_safe) [tgcolmisc1]"
		}
		[tgpriv] $nick "[tgbold]$_who [tgcolmisc2]$tgscoresbyname($_text_safe)[tgcolmisc1] puanı var, [tgcolmisc2]$tgscorestotal[tgcolmisc1] [tgcolmisc1]kişi içinde [tgcolmisc2]$_siralama. sırada"
	}
}

#triggered when someone /msgs the bot with the target lookup command.
proc tgtargetlookup {nick host hand text} {
	global tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames
	tggetscores
	set _nick_safe [tg_norm $nick]
	if {![info exists tgscoresbyname($_nick_safe)]} {
		[tgpriv] $nick "[tgbold][tgcolmisc1]Skor tablosunda yer almıyorsunuz."
	} elseif {$tgranksbyname($_nick_safe)==1} {
		[tgpriv] $nick "[tgbold][tgcolmisc1]Birinci sıradasınız!"
	} else {
		set _onceki_rank [expr $tgranksbyname($_nick_safe)-1]
		set _onceki_safe $tgranksbynum($_onceki_rank)
		[tgpriv] $nick "[tgbold][tgcolmisc1]Toplam puanınız [tgcolmisc2]$tgscoresbyname($_nick_safe)[tgcolmisc1]. Hemen önünüzde [tgcolmisc2]$tgrealnames($_onceki_safe) [tgcolmisc1] puanla [tgcolmisc2]$tgscoresbyrank($_onceki_rank)[tgcolmisc1], sırada [tgcolmisc2][ordnumber $_onceki_rank] [tgcolmisc2]$tgscorestotal[tgcolmisc1] [tgcolmisc1] kişi arasında."
	}
}

#triggered when someone /msgs the bot with the error reporting command.
proc tgerror {nick host hand text} {
	global tgquestionstotal tgquestionslist tgerrmethod tgerrfil tgerremail tgerrmailtmp
	if {$text==""||![string is int [lindex [split $text] 0]]} {
		[tgpriv] $nick "[tgbold][tgcolmisc1]Soru numarası girmediniz."
		return
	}
	tgreadqdb
	set _qnum [lindex [split $text] 0]
	if {$_qnum>$tgquestionstotal} {
		[tgpriv] $nick "[tgbold][tgcolmisc1]Bu numaraya ait soru bulunamadı."
		return
	}
	set _qques [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 1]
	set _qans [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 0]
	set _desc [join [lrange [split $text] 1 end]]
	if {$_desc==""} { set _desc "Bu hata ile ilgili daha fazla bilgi yok." }
	if {$tgerrmethod==1} {
		set _fname $tgerrmailtmp\trivia[rand 100000].tmp
		set _file [open $_fname w]
	} else {
		set _file [open $tgerrfil a]
	}
	puts $_file ""
	puts $_file "Error report generated [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S]"
	puts $_file "raporu bildiren:\t$nick!$host"
	puts $_file "SoruNo #:\t$_qnum"
	puts $_file "Soru:\t$_qques"
	puts $_file "Cevap:\t\t$_qans"
	puts $_file "Mesaj:\t$_desc"
	puts $_file "------------------------------"
	close $_file
	if {$tgerrmethod==1} {
		exec mail -s "trivia.tcl error report from $nick" $tgerremail < $_fname
		file delete $_fname
		[tgpriv] $nick "[tgbold][tgcolmisc1]Teşekkürler! hatalı soru e-mail yolu ile yetkililere ulastirilacaktir."
	} else {
		[tgpriv] $nick "[tgbold][tgcolmisc1]Teşekkürler! hatalı soru kaydedildi ve en kısa zamanda yetkililere bildirilecektir."
	}
}

#triggered when someone /msgs the bot with the rules command.
proc tgrulesmsg {nick host hand text} {
	global tgrules
	[tgpriv] $nick "Oyun kuralları: $tgrules"
}

#triggered when someone /msgs the bot with the help command.
proc tggivehelp {nick host hand {text ""}} {
	global botnick tgcmdlookup tgcmdhelp tgcmdstart tgcmdstop tgchan tgflagsstop
	global tgcmdstop tgflagshint tgcmdhint tgflagsskip tgcmdskip tgflagsreset tgcmdreset
	global tgcmdtarget tgcmderror tgcmdrules tgflagsstart
	if {$text==""} {
		[tgpriv] $nick "komutlar hakkında yardım almak için:"
		[tgpriv] $nick "/MSG $botnick <komut> yazmalısınız"
		[tgpriv] $nick "  \002[strupr $tgcmdrules]\002"
		[tgpriv] $nick "   -- Kanal kurallarını listelemek için."
		[tgpriv] $nick "  \002[strupr $tgcmdlookup]\002 \[nick\]"
		[tgpriv] $nick "   -- Belirtilen \[nick\] sirasini ve skorunu verir"
		[tgpriv] $nick "    Eger bir nick belirtilmezse sizin bilgileriniz gosterilecektir."
		[tgpriv] $nick "  \002[strupr $tgcmdtarget]\002"
		[tgpriv] $nick "   -- Belirtilen kullanici ile sizin aranizdaki"
		[tgpriv] $nick "    sira sayisini ve skor farkini gosterir."
		[tgpriv] $nick "  \002[strupr $tgcmderror]\002 <number> \[description\]"
		[tgpriv] $nick "   -- numarasi belirtilen sorunun varsa hatalarini bildirmenizi saglar"
		[tgpriv] $nick "    hata aciklamasi kismini yazmayabilirsiniz..."
		if {[matchattr $hand $tgflagsreset $tgchan]} {
			[tgpriv] $nick "  \002[strupr $tgcmdreset]\002"
			[tgpriv] $nick "   -- Skor tablosunu siler."
		}
		[tgpriv] $nick "Kanalda kullanabileceginiz komutlarin listesini gormek icin"
            [tgpriv] $nick "/MSG $botnick [strupr $tgcmdhelp] PUBCMDS yazin"
	}
	if {[strlwr $text]=="pubcmds"} {
		[tgpriv] $nick "Kullanabileceğiniz kanal komutları:"
		if {[matchattr $hand $tgflagsstart $tgchan]} {
			[tgpriv] $nick "  \002$tgcmdstart\002 -- Oyunu başlatır."
		}
		if {[matchattr $hand $tgflagsstop $tgchan]} {
			[tgpriv] $nick "  \002$tgcmdstop\002 -- Oyunu durdurur."
		}
		if {[matchattr $hand $tgflagshint $tgchan]} {
			[tgpriv] $nick "  \002$tgcmdhint\002 -- Soru hakkında ipucu verir."
		}
		if {[matchattr $hand $tgflagsskip $tgchan]} {
			[tgpriv] $nick "  \002$tgcmdskip\002 -- Soruyu atlar."
		}
		[tgpriv] $nick "komutlarin listesi icin, /MSG $botnick [strupr $tgcmdhelp] yazin."
	}
}

# Returns text without colour, bold, etc. control codes.
# This is a stripped down version of the proc in MC_8's mc.moretools.tcl.
proc tgstripcodes {text} {
	regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
	set text "[string map -nocase[list \002 "" \017 "" \026 "" \037 ""] $text]"
	return $text
}

proc tggamemsg {what} {
	global tgchan
	putquick "PRIVMSG $tgchan :[tgbold]$what"
}

proc tgbold {} {
	global tgusebold
	if {$tgusebold==1} { return "\002" }
}
proc tgcolstart {} {
	global tgcolourstart
	if {$tgcolourstart!=""} { return "\003$tgcolourstart" }
}
proc tgcolstop {} {
	global tgcolourstop
	if {$tgcolourstop!=""} { return "\003$tgcolourstop" }
}
proc tgcolskip {} {
	global tgcolourskip
	if {$tgcolourskip!=""} { return "\003$tgcolourskip" }
}
proc tgcolerr {} {
	global tgcolourerr
	if {$tgcolourerr!=""} { return "\003$tgcolourerr" }
}
proc tgcolmiss {} {
	global tgcolourmiss
	if {$tgcolourmiss!=""} { return "\003$tgcolourmiss" }
}
proc tgcolqhead {} {
	global tgcolourqhead
	if {$tgcolourqhead!=""} { return "\003$tgcolourqhead" }
}
proc tgcolqbody {} {
	global tgcolourqbody
	if {$tgcolourqbody!=""} { return "\003$tgcolourqbody" }
}
proc tgcolhint {} {
	global tgcolourhint
	if {$tgcolourhint!=""} { return "\003$tgcolourhint" }
}
proc tgcolstrk {} {
	global tgcolourstrk
	if {$tgcolourstrk!=""} { return "\003$tgcolourstrk" }
}
proc tgcolscr1 {} {
	global tgcolourscr1
	if {$tgcolourscr1!=""} { return "\003$tgcolourscr1" }
}
proc tgcolscr2 {} {
	global tgcolourscr2
	if {$tgcolourscr2!=""} { return "\003$tgcolourscr2" }
}
proc tgcolscr3 {} {
	global tgcolourscr3
	if {$tgcolourscr3!=""} { return "\003$tgcolourscr3" }
}
proc tgcolrset {} {
	global tgcolourrset
	if {$tgcolourrset!=""} { return "\003$tgcolourrset" }
}
proc tgcolstend {} {
	global tgcolourstend
	if {$tgcolourstend!=""} { return "\003$tgcolourstend" }
}
proc tgcolmisc1 {} {
	global tgcolourmisc1
	if {$tgcolourmisc1!=""} { return "\003$tgcolourmisc1" }
}
proc tgcolmisc2 {} {
	global tgcolourmisc2
	if {$tgcolourmisc2!=""} { return "\003$tgcolourmisc2" }
}
proc tgpriv {} {
	global tgpriv2msg
	if {$tgpriv2msg==1} { return "putmsg" } else { return "putnotc" }
}
proc tgantihack {} {
	global tgcolantihack
	if {$tgcolantihack!=""} { return "\003$tgcolantihack" }
}
proc merlin {} {
	return "\00300,04Bu kelimeyi düzenleyin :  "
}

#this generates an html file with all the people on the chan with
#their score, as well as a list of all scores, sorted by rank
proc tghtml {} {
	global tgchan botnick tghtmlfile tghtmlrefresh server tgscoresbyname tgranksbyname
	global tgscorestotal tgranksbyname tgrealnames tgscoresbyrank tgranksbynum tgplaying
	global tgquestionstotal tghtmlrefreshtimer tghtmlfont
	tggetscores
	tgreadqdb
	set _file [open $tghtmlfile~new w]
	puts $_file "<!DOCTYPE HTML PUBLIC \"-/W3C/DTD HTML 4.01 Transitional/EN\">"
	puts $_file "<html>"
	puts $_file " <head>"
	puts $_file "  <title>$botnick's trivia channel: $tgchan on [lindex [split $server :] 0]</title>"
	puts $_file "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
	puts $_file "  <meta http-equiv=\"refresh\" content=\"$tghtmlrefresh\">"
	puts $_file "  <meta name=\"generator\" content=\"trivia.tcl script for eggdrop. http://www.eggdrop.za.net/\">"
	puts $_file "  <style type=\"text/css\">"
	puts $_file "  <!--"
	puts $_file "  body,td{font-family:$tghtmlfont;font-size:13px;}"
	puts $_file "  a{text-decoration:none;color:#09f;}"
	puts $_file "  -->"
	puts $_file "  </style>"
	puts $_file " </head>"
	puts $_file " <body>"
	puts $_file "  <h1>$tgchan on [lindex [split $server :] 0]</h1>"
	puts $_file "  <hr size=\"1\" noshade>"
	if {![onchan $botnick $tgchan]} {
		puts $_file "  <p>Hmmm... for some reason I'm not on $tgchan at the moment. Please try again later.</p>"
	} else {
		puts $_file "  <p>Trivia game is currently <b>[expr $tgplaying==1?"on":"off"]</b>. There are <b>$tgquestionstotal</b> questions in the database."
		puts $_file "  <p>People on $tgchan right now:<br>"
		puts $_file "  <table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" cellspacing=\"3\" border=\"0\">"
		puts $_file "   <tr>"
		puts $_file "    <td><b>Nick</b></td>"
		puts $_file "    <td><b>Score</b></td>"
		puts $_file "    <td><b>Rank</b></td>"
		puts $_file "    <td><b>Idle</b></td>"
		puts $_file "   </tr>"
		foreach nick [lsort [chanlist $tgchan]] {
			puts $_file "   <tr>"
			puts $_file "    <td>[expr [isop $nick $tgchan]?"@":""][expr [isvoice $nick $tgchan]?"+":""]$nick[expr [string match $nick $botnick]?" (that's me!)":""]</td>"
			set _nick_safe [tg_norm $nick]
			if {[info exists tgscoresbyname($_nick_safe)]} {
				puts $_file "    <td>$tgscoresbyname($_nick_safe)</td>"
			} else {
				puts $_file "    <td>-</td>"
			}
			if {[info exists tgranksbyname($_nick_safe)]} {
				puts $_file "    <td>$tgranksbyname($_nick_safe)</td>"
			} else {
				puts $_file "    <td>-</td>"
			}
			puts $_file "   <td>[expr [getchanidle $nick $tgchan]>10?"[getchanidle $nick $tgchan]m":"-"]</td>"
			puts $_file "   </tr>"
		}
		puts $_file "  </table></td></tr></table>"
	}
	if {$tgscorestotal>0} {
		puts $_file "  <p><small>There [expr $tgscorestotal==1?"is":"are"] currently <b>$tgscorestotal</b> [expr $tgscorestotal==1?"nick":"nicks"] in the score table:<br>"
		set _rank 1
		while {$_rank<=$tgscorestotal} {
			puts $_file "  <b>$_rank</b>. $tgrealnames($tgranksbynum($_rank)) $tgscoresbyrank($_rank)<br>"
			incr _rank
		}
	} else {
		puts $_file "  <p><small>There are currently no nicks in the score table.<br>"
	}
	puts $_file "  </small></p>"
	puts $_file "  <hr size=\"1\" noshade>"
	puts $_file "  <small>Generated on [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S] by <a href=\"http://www.eggdrop.za.net/\">trivia.tcl</a> for <a href=\"http://www.eggheads.org\">eggdrop</a>.<br>"
	puts $_file "  This page is automatically updated (and refreshed if supported by your browser) every [expr $tghtmlrefresh==1?"second":"$tghtmlrefresh seconds"].</small>"
	puts $_file " </body>"
	puts $_file "</html>"
	close $_file
	file rename -force $tghtmlfile~new $tghtmlfile
	set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}


# ============================================
# YENİ ÖZELLİKLER: Topic, Ay Başı Sıfırlama, Ödül Sistemi
# ============================================

# Ay başı sıfırlama ayarları
set tgmonthlyreset 1          ;# Ay başı otomatik sıfırlama aktif (1) / pasif (0)
set tgmonthlyresetday 1       ;# Hangi gün sıfırlansın (1 = ayın 1'i)
set tgmonthlyresethour 0      ;# Saat kaçta sıfırlansın (0 = gece yarısı)
set tgmonthlyresetmin 0       ;# Dakika kaçta sıfırlansın

# Ödül ayarları
set tgprize1voice 1           ;# 1. olan voice alsın (1) / almasın (0)
set tgprize2voice 1           ;# 2. olan voice alsın (1) / almasın (0)
set tgprize3voice 1           ;# 3. olan voice alsın (1) / almasın (0)

# Topic ayarları
set tgautotopic 1             ;# Otomatik topic güncelleme aktif (1) / pasif (0)
set tgtopicinterval 7200      ;# Topic güncelleme aralığı (saniye) - 2 saat = 7200
set tgtopicprefix "Top10: "   ;# Topic öneki
set tgtopicsuffix ""          ;# Topic son eki

# Önceki ayın kazananlarını sakla (özel karşılama için)
set tglastmonthwinners ""     ;# "nick1,nick2,nick3" formatında

# ============================================
# AY BAŞI SIFIRLAMA SİSTEMİ
# ============================================

# Bir sonraki ay başı sıfırlama zamanını hesapla
proc tggetnextmonthlyreset {} {
    global tgmonthlyresetday tgmonthlyresethour tgmonthlyresetmin

    set now [clock seconds]
    set now_tm [clock format $now -format "%m %Y"]
    set month [lindex $now_tm 0]
    set year [lindex $now_tm 1]

    # Bir sonraki ayı hesapla
    if {$month == 12} {
        set next_month 1
        set next_year [expr $year + 1]
    } else {
        set next_month [expr $month + 1]
        set next_year $year
    }

    # Bir sonraki ayın ilk gününün timestamp'i
    set next_reset [clock scan "$next_year-$next_month-$tgmonthlyresetday $tgmonthlyresethour:$tgmonthlyresetmin:00" -format "%Y-%m-%d %H:%M:%S"]

    return $next_reset
}

# Ay başı sıfırlama kontrolü
proc tgcheckmonthlyreset {} {
    global tgmonthlyreset tgscf tgscores tgscorestotal tgchan tgplaying
    global tglastmonthwinners

    if {!$tgmonthlyreset} {
        # Sıfırlama pasifse, bir sonraki kontrol için timer kur
        timer 60 tgcheckmonthlyreset
        return
    }

    set now [clock seconds]
    set current_day [clock format $now -format "%d"]
    set current_hour [clock format $now -format "%H"]
    set current_min [clock format $now -format "%M"]

    global tgmonthlyresetday tgmonthlyresethour tgmonthlyresetmin

    if {$current_day == $tgmonthlyresetday && $current_hour == $tgmonthlyresethour && $current_min == $tgmonthlyresetmin} {
        # AY BAŞI SIFIRLAMA ZAMANI!
        tggetscores

        # Önceki ayın kazananlarını kaydet (özel karşılama için)
        set tglastmonthwinners ""
        set winner_list {}

        for {set i 0} {$i < 3 && $i < $tgscorestotal} {incr i} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            lappend winner_list $_nick
        }
        set tglastmonthwinners [join $winner_list ","]

        # Skorları sıfırla
        if {[file exists $tgscf] && [file size $tgscf] > 2} {
            set _sfile [open $tgscf w]
            puts $_sfile ""
            close $_sfile
            set tgscores ""
            set tgscorestotal 0
        }

        # Kanala duyuru
        tggamemsg "\00304=== YENİ AY - SKORLAR SIFIRLANDI! ==="

        if {[llength $winner_list] > 0} {
            set _msg "\00306Geçen ayın kazananları: "
            if {[llength $winner_list] >= 1} {
                append _msg "\003041. [lindex $winner_list 0]"
            }
            if {[llength $winner_list] >= 2} {
                append _msg "\00312, 2. [lindex $winner_list 1]"
            }
            if {[llength $winner_list] >= 3} {
                append _msg "\00303, 3. [lindex $winner_list 2]"
            }
            tggamemsg "$_msg"
            tggamemsg "\00306Bu kullanıcılara özel karşılama ve voice verilecektir!"
        }

        # Topic'i güncelle (boş skor tablosuyla)
        if {[info exists tgautotopic] && $tgautotopic} {
            tgupdatetopic
        }
    }

    # Her dakika kontrol et
    timer 60 tgcheckmonthlyreset
}


# Top 10 listesini topic'e yaz
proc tgupdatetopic {} {
    global tgchan tgautotopic tgtopicprefix tgtopicsuffix
    global tgscores tgscorestotal

    if {!$tgautotopic} return

    tggetscores

    set _topic "$tgtopicprefix"

    if {$tgscorestotal > 0} {
        set _toplist {}
        set _max [expr $tgscorestotal > 10 ? 9 : [expr $tgscorestotal - 1]]

        for {set i 0} {$i <= $_max} {incr i} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _score [lindex [split $_item ,] 0]

            if {$i == 0} {
                lappend _toplist "\00304$_nick\003($_score)"
            } elseif {$i == 1} {
                lappend _toplist "\00312$_nick\003($_score)"
            } elseif {$i == 2} {
                lappend _toplist "\00303$_nick\003($_score)"
            } else {
                lappend _toplist "$_nick($_score)"
            }
        }

        append _topic [join $_toplist " | "]
    } else {
        append _topic "Henüz skor yok - !basla ile oyunu başlat!"
    }

    append _topic $tgtopicsuffix

    # Topic'i güncelle
    putquick "TOPIC $tgchan :$_topic"

    # Bir sonraki 2 saatlik timer'ı kur
    if {[info exists tgautotopic] && $tgautotopic} {
        set tgtopictimer [timer $tgtopicinterval tgupdatetopic]
    }
}


# Ayın kazananlarına özel karşılama ve voice
proc tgcheckprizewinner {nick} {
    global tglastmonthwinners tgchan tgprize1voice tgprize2voice tgprize3voice

    if {$tglastmonthwinners == ""} return

    set _winners [split $tglastmonthwinners ","]
    set _nick_safe [tg_norm $nick]

    set _rank 0
    for {set i 0} {$i < [llength $_winners]} {incr i} {
        if {[tg_norm [lindex $_winners $i]] eq $_nick_safe} {
            set _rank [expr $i + 1]
            break
        }
    }

    if {$_rank == 0} return

    # Özel karşılama mesajı
    set _msg ""
    if {$_rank == 1} {
        set _msg "\00304[ GEÇEN AYIN BİRİNCİSİ ] \00306$nick\00304 BİZE KATILDI!"
        if {$tgprize1voice && [botisop $tgchan] && ![isvoice $nick $tgchan] && ![isop $nick $tgchan]} {
            putquick "MODE $tgchan +v $nick"
            append _msg " \00306(+v ödülü verildi!)"
        }
    } elseif {$_rank == 2} {
        set _msg "\00312[ GEÇEN AYIN İKİNCİSİ ] \00306$nick\00312 BİZE KATILDI!"
        if {$tgprize2voice && [botisop $tgchan] && ![isvoice $nick $tgchan] && ![isop $nick $tgchan]} {
            putquick "MODE $tgchan +v $nick"
            append _msg " \00306(+v ödülü verildi!)"
        }
    } elseif {$_rank == 3} {
        set _msg "\00303[ GEÇEN AYIN ÜÇÜNCÜSÜ ] \00306$nick\00303 BİZE KATILDI!"
        if {$tgprize3voice && [botisop $tgchan] && ![isvoice $nick $tgchan] && ![isop $nick $tgchan]} {
            putquick "MODE $tgchan +v $nick"
            append _msg " \00306(+v ödülü verildi!)"
        }
    }

    if {$_msg != ""} {
        tggamemsg "$_msg"
    }
}


proc tgshowlastwinners {nick host hand chan text} {
    global tglastmonthwinners tgchan
    if {[strlwr $chan] == [strlwr $tgchan]} {
        if {$tglastmonthwinners == ""} {
            tggamemsg "\00306Henüz geçen ayın kazananı kaydedilmemiş."
        } else {
            set _winners [split $tglastmonthwinners ","]
            set _msg "\00306Geçen ayın kazananları: "
            if {[llength $_winners] >= 1} {
                append _msg "\003041. [lindex $_winners 0]"
            }
            if {[llength $_winners] >= 2} {
                append _msg "\00312, 2. [lindex $_winners 1]"
            }
            if {[llength $_winners] >= 3} {
                append _msg "\00303, 3. [lindex $_winners 2]"
            }
            tggamemsg "$_msg"
        }
    }
}


putlog "#####################################"
putlog "#     https://www.Sohbetlive.com.tr     #"
putlog "#####################################"
Ek olarak !aybirincisi otomatik topic ay başı top10 sıralama silme eklendi.
Çoğu serverlar'da turkce karakter nicklerde sorun var. Güncelledim keyifle kullanabilirsiniz.
________________

Hersey icin fazla sanalsiniz.
 
Alt 07 Ağustos 2026, 01:39   #2
ßαzεη çïçεκ ßαzεη ƒεレâκε†
iz` - ait Kullanıcı Resmi (Avatar)

Standart

Emeğinize sağlık paylaşım için teşekkürler

________________

𝖎𝖘𝖙𝖊𝖉𝖎ğ𝖎𝖒 𝖖𝖎𝖇𝖎 𝖔𝖑𝖒𝖆𝖟𝖘𝖆 𝖎𝖘𝖙𝖊𝖒𝖊𝖒!
 
Alt 07 Ağustos 2026, 01:47   #3
Zamanın izleri kalır...
Zenia - ait Kullanıcı Resmi (Avatar)

Standart

Emeginize sağlık

________________

 
Alt 07 Ağustos 2026, 10:37   #4
civciv~🐥
Sim - ait Kullanıcı Resmi (Avatar)

Standart

paylasim icin tesekkürler

________________

"frangar, non flectar."
 
Alt 07 Ağustos 2026, 10:43   #5
portrait of beauty
Raina - ait Kullanıcı Resmi (Avatar)

Standart

Oldukça emek sarf edilmiş emeğine sağlık

________________

Kaliteli insan işiyle , boş insan kişiyle uğraşır !!!
 
Alt 08 Ağustos 2026, 10:01   #6
Standart

Elinize sağlık, bayağı uğraşılmış belli güzel iş çıkarmışsınız 👏

________________

 
Alt 08 Ağustos 2026, 10:27   #7
"En güzel insan, güven verendir." Diamond
Diamond - ait Kullanıcı Resmi (Avatar)

Standart

Emeği geçen herkese teşekkürler.

________________

Edep, içsel güzellik ve dışsal davranışlarımız arasındaki köprüdür.
 
Alt 08 Ağustos 2026, 10:28   #8
tüm mümkünlєrín kıчıѕındαчım
BerduŞ - ait Kullanıcı Resmi (Avatar)

Standart

Ben bıraktıktan sonra çözülmüş :)

________________

 
Alt 08 Ağustos 2026, 14:22   #9
Standart

Emeğine sağlık.

________________

🍒
𝑯𝒆𝒓 𝒉𝒊𝒌𝒂𝒚𝒆𝒏𝒊𝒏 𝒊𝒌𝒊 𝒕𝒂𝒓𝒂𝒇𝒊 𝒗𝒂𝒓𝒅𝒊𝒓.
: ( :
 
Alt 11 Ağustos 2026, 15:08   #10
Sahtesiniz Sahte
JeSteR - ait Kullanıcı Resmi (Avatar)

Standart

emeğine sağlık kanka :)

________________

[Üye Olmadan Linkleri Göremezsiniz. Lütfen Üye Olmak için TIKLAYIN...]
 


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 

Yetkileriniz
Konu Acma Yetkiniz Yok
Cevap Yazma Yetkiniz Yok
Eklenti Yükleme Yetkiniz Yok
Mesajınızı Değiştirme Yetkiniz Yok

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-Kodu Kapalı
Trackbacks are Kapalı
Pingbacks are Kapalı
Refbacks are Kapalı





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