just to show you, that there is no problem at general to write umlaute and read them again. this from a dcc session from mIRC with 100% NO UTF-8 support console<StarZ|Clan> [20:18:01] tcl: evaluate (.tcl): open test.txt w
<StarZ|Clan> Tcl: file17
<StarZ|Clan> [20:18:20] tcl: evaluate (.tcl): puts file17 "Hallö"
<StarZ|Clan> Tcl:
<StarZ|Clan> [20:18:30] tcl: evaluate (.tcl): close file17
<StarZ|Clan> Tcl:
<StarZ|Clan> [20:18:38] tcl: evaluate (.tcl): open test.txt r
<StarZ|Clan> Tcl: file17
<StarZ|Clan> [20:18:46] tcl: evaluate (.tcl): read file17
<StarZ|Clan> Tcl: Hallö
<StarZ|Clan> [20:18:59] tcl: evaluate (.tcl): close file17
<StarZ|Clan> Tcl:
Code: Select all
# x quotes will be posted in y seconds
set qot(flood) 3:10
# ignore flooders?
set qot(ignore) 1
# ignore time in minutes
set qot(ignore_time) 1
# Public command trigger
set qot(pubtrigger) {!}
# Quote Storage File
set qot(file) "scripts/dbase/quotes"
### DO NOT CHANGE THE FOLLOWING VALUES IF NOT NECESSARY (usually not)
### Changing these might cause the script to stop working
bind pub -|- ${qot(pubtrigger)}quote qot_random
bind pub -|- ${qot(pubtrigger)}lastquote qot_last
bind pub o|- ${qot(pubtrigger)}addquote qot_addquote
bind pub m|- ${qot(pubtrigger)}delquote qot_del
proc srand {int} {
if {[catch {expr $int} int]} {
error "random limit must be greater than zero"
} elseif {!$int} {
error "random limit must be greater than zero"
}
return [expr [clock clicks] % $int]
}
proc qot_flood_init {} {
global qot qot_flood_array
if {![file isdirectory [file dirname $qot(file)]]} {
file mkdir [file dirname $qot(file)]
}
if {![regexp {^([0-9]+):([0-9]+)$} $qot(flood) tmp qot(flood_num) qot(flood_time)]} {
putcmdlog "Quote TCL: var qot(flood) not set correctly."
return
}
set i [expr $qot(flood_num) - 1]
while {$i >= 0} {
set qot_flood_array($i) 0
incr i -1
}
}
qot_flood_init
proc qot_flood {nick uhost} {
global qot qot_flood_array
if {$qot(flood_num) == 0} {
return 0
}
set i [expr $qot(flood_num) - 1]
while {$i >= 1} {
set qot_flood_array($i) $qot_flood_array([expr $i - 1])
incr i -1
}
set qot_flood_array(0) [unixtime]
if {[expr [unixtime] - $qot_flood_array([expr $qot(flood_num) - 1])] <= $qot(flood_time)} {
if {$qot(ignore)} {
newignore [maskhost [getchanhost $nick]] Quote-TCL "$nick flooded the quote script." $qot(ignore_time)
}
return 1
} else {
return 0
}
}
proc qot_random {nick uhost hand chan text} {
global qot
if {![matchattr $hand o|o $chan]} {
if {[qot_flood $nick $uhost]} {
return 0
}
}
if {![file exists $qot(file)]} {
putquick "PRIVMSG $chan :Error: No quotes found, file doesn't exist."
return 0
}
set file [open $qot(file) r+]
for {set count 1} {![eof $file]} {incr count} {
gets $file quotes($count)
}
close $file
set count [array size quotes]
unset quotes($count)
incr count -1
if {[string length [string trim $text *?]] == 0} {
set value [srand $count+1]
set current [expr {($value == 0) ? 1 : $value}]
set quote $quotes($current)
putquick "PRIVMSG $chan :Quote \002$current/$count\002 $quote"
return 1
} elseif {[regexp {^\d+$} $text]} {
if {![info exists quotes($text)]} {
putquick "PRIVMSG $chan :Error: That quote doesn't exist."
return 1
} else {
set quote $quotes($text)
putquick "PRIVMSG $chan :Quote \002$text/$count\002 $quote"
return 1
}
} else {
set text [string trim $text *]
array set nquotes ""
for {set current 1} {$current <= $count} {incr current} {
if {[string match -nocase *[qot_clean $text]* $quotes($current)]} {
regsub -all -nocase -- "([qot_rclean $text])" $quotes($current) "\002\\1\002" quotes($current)
set nquotes($current) $quotes($current)
}
}
if {[array size nquotes] == 0} {
putquick "PRIVMSG $chan :No quotes matching '$text' found."
} else {
set value [lindex [array names nquotes] [srand [array size nquotes]]]
set quote $nquotes($value)
putquick "PRIVMSG $chan :Quote \002$value/$count\002 $quote"
}
}
}
proc qot_addquote {nick uhost hand chan text} {
global qot;
set file [open $qot(file) a+];
puts $file [stripcodes uacgbr $text];
close $file;
putquick "NOTICE $nick :Added quote to storage facility.";
}
proc qot_del {nick uhost hand chan text} {
global qot
set delnum $text
set type [lindex $text 0]
set text [lrange $text 1 end]
if {![file exists $qot(file)]} {
putquick "PRIVMSG $chan :Error: No quotes found, file doesn't exist."
return
} else {
set qot_fd [open $qot(file) r]
}
for {set qot_cnt 0} {![eof $qot_fd]} {incr qot_cnt 1} {
gets $qot_fd qot_list($qot_cnt)
}
close $qot_fd
set qot_cnt [expr $qot_cnt - 2]
if {[string is integer $delnum]} {
set qot_fd [open $qot(file) w]
for {set i 0} {$i <= $qot_cnt} {incr i 1} {
if {($qot_list($i) == "") || ($i == [expr $delnum - 1])} {
putquick "PRIVMSG $chan :Quote [expr $i + 1] deleted"
continue
} else {
puts $qot_fd $qot_list($i)
}
}
close $qot_fd
} elseif {$type == "num"} {
set qot_fd [open $qot(file) w]
for {set i 0} {$i <= $qot_cnt} {incr i 1} {
if {($qot_list($i) == "") || ($i == [expr $text - 1])} {
putquick "NOTICE $nick :Quote [expr $i + 1] deleted"
continue
} else {
puts $qot_fd $qot_list($i)
}
}
close $qot_fd
}
}
proc qot_last {nick uhost hand chan text} {
global qot
if {[qot_flood $nick $uhost]} {
return 0
}
if {![file exists $qot(file)]} {
putquick "PRIVMSG $chan :Error: No quotes found, file doesn't exist."
return
} else {
set qot_fd [open $qot(file) r]
}
for {set qot_cnt 0} {![eof $qot_fd]} {incr qot_cnt} {
gets $qot_fd qot_list($qot_cnt)
}
close $qot_fd
set qot_cnt [expr $qot_cnt - 2]
set qot(last) $qot_list([expr $qot_cnt])
putquick "PRIVMSG $chan :Quote \002[expr $qot_cnt + 1]/[expr $qot_cnt + 1]\002 $qot(last)"
return
}
proc qot_rclean {i} {
regsub -all -- {([\(\)\[\]\{\}\!\|\.\$\^\"\\])} $i {\\\1} i
regsub -all -- {(\?)} $i "." i
regsub -all -- {(\*)} $i ".*?" i
return $i
}
proc qot_clean {i} {
regsub -all -- {([\(\)\[\]\{\}\$\"\\])} $i {\\\1} i
return $i
}
putlog "Loaded quote.tcl by perpleXa"