bind pub -Nekobot, nkb_main
proc nkb_main {nick uhost hand chan args } {
set arg1 [lindex [split $args] 0]
set arg2 [lindex [split $args] 1]
putlog "arg2 is '$arg2'"if {$arg1=="flip"} {
if {$arg2=="heads"} {
set mode 1
} elseif {$arg2=="tails"} {
set mode 2
} else {
set mode 0
}
flip_coin $chan$nick$mode
} elseif {$arg1=="kitty"} {
give_kitty($nick,$uhost,$hand,$chan,$args)
}
}
proc flip_coin {chan nick mode } {
set coin [expr int(rand()*2)]
if {$coin==0} {
set coin_txt "Heads"
} else {
set coin_txt "Tails"
}
if {$mode==0} {
putchan $chan"${nick} flipped a ${coin_txt}!"return0
} elseif {$mode==1} {
if {$coin==0} {
set won "won"
} else {
set won "lost"
}
} elseif {$mode==2} {
if {$coin==1} {
set won "won"
} else {
set won "lost"
}
}
putchan $chan"${nick} ${won} with a ${coin_txt}"return0
}