Some fixes for the `coin' plugin
Hey, I'm pretty new to Tcl, leave me alone.
This commit is contained in:
parent
9d0a276f93
commit
c2ddcc937e
18
plugins/coin
18
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 == ""} {
|
||||
|
Loading…
Reference in New Issue
Block a user