aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-24 00:33:29 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-24 00:33:29 +0200
commitc2ddcc937edede2755635a44a4d3934a78c271f1 (patch)
treefb408e34787ec0a5da047c282a947cc2bc55529c /plugins
parent9d0a276f93dd8fe0137c9818779cba6555102b1f (diff)
downloadxK-c2ddcc937edede2755635a44a4d3934a78c271f1.tar.gz
xK-c2ddcc937edede2755635a44a4d3934a78c271f1.tar.xz
xK-c2ddcc937edede2755635a44a4d3934a78c271f1.zip
Some fixes for the `coin' plugin
Hey, I'm pretty new to Tcl, leave me alone.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/coin18
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/coin b/plugins/coin
index 44a1448..cf9b29b 100755
--- a/plugins/coin
+++ b/plugins/coin
@@ -23,15 +23,15 @@ proc parse {line} {
while {1} {
set line [string trimleft $line " "]
set i [string first " " $line]
- if {$i == -1} { set i [string bytelength $line] }
+ if {$i == -1} { set i [string length $line] }
if {$i == 0} { break }
if {[string index $line 0] == ":"} {
- lappend msg(param) [string range $line 1 [string bytelength $line]]
+ lappend msg(param) [string range $line 1 end]
break
}
lappend msg(param) [string range $line 0 [expr $i - 1]]
- set line [string range $line $i [string bytelength $line]]
+ set line [string range $line $i end]
}
}
@@ -49,8 +49,8 @@ proc pmrespond {text} {
puts "PRIVMSG $ctx :$ctx_quote$text"
}
-fconfigure stdin -translation crlf
-fconfigure stdout -translation crlf
+fconfigure stdin -translation crlf -encoding iso8859-1
+fconfigure stdout -translation crlf -encoding iso8859-1
set prefix [get_config prefix]
puts "ZYKLONB register"
@@ -92,10 +92,9 @@ while {[gets stdin line] != -1} {
set input [lindex $msg(param) 1]
set first_chars [string range $input 0 \
- [expr [string bytelength $prefix] - 1]]
+ [expr [string length $prefix] - 1]]
if {$first_chars != $prefix} { continue }
- set input [string range $input \
- [string bytelength $prefix] [string bytelength $input]]
+ set input [string range $input [string length $prefix] end]
if {$input == "coin"} {
if {rand() < 0.5} { pmrespond "Heads." } else { pmrespond "Tails." }
@@ -110,7 +109,8 @@ while {[gets stdin line] != -1} {
pmrespond "Nothing to choose from."
} else {
set c [split $args ",|"]
- pmrespond [lindex $c [expr {int([llength $c] * rand())}]]
+ pmrespond [string trim [lindex $c \
+ [expr {int([llength $c] * rand())}]]]
}
} elseif {[regexp {^eightball( +|$)(.*)} $input -> _ args]} {
if {$args == ""} {