1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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}!"
                return 0
        } 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}"
        return 0
}