#!/usr/bin/expect -- set complaints { {say something!} {this is boring...} {zzzzzzz} {where is everyone?} {peek-a-boo} {moo} {hm...} {anyone here?} } set greetings { {Hello} {Heya} {Hi there} {Yo} } set moods { {not too bad, thank you} {just dandy} {i guess i'll survive} {top of the world!} {under the circumstances, pretty well thank you} } set doings { {not much really} {hm... good question} {i'm picking my nose} {guess:)} } set timeout 600 spawn irc -c #linux EBot alicja.dyns.cx expect { -re {<.+> +[Ee][Bb]ot: *(.*)$} { set s $expect_out(1,string) if {[string match {calendar*} $s]} { set s [exec calendar] set lines [split $s \n] foreach l $lines { set l [string map {\t " "} $l] send "$l\r" after 500 } exp_continue } if {[string match {fortune*} $s]} { set s [exec fortune] set lines [split $s \n] foreach l $lines { set l [string map {\t " "} $l] send "$l\r" after 500 } exp_continue } exp_continue } -re {<(.+)> ([Hh]ello|[Hh]i|[Hh]ey)[, ] *[Ee][Bb]ot.*$} { set n [expr {int(rand() * [llength $greetings])}] send "[lindex $greetings $n], $expect_out(1,string)\r" exp_continue } -re {<(.+)> [Hh]ow are you[, ] *[Ee][Bb]ot.*$} { set n [expr {int(rand() * [llength $moods])}] send "[lindex $moods $n]\r" exp_continue } -re {<(.+)> [Ww]hat's up[, ] *[Ee][Bb]ot.*$} { set n [expr {int(rand() * [llength $doings])}] send "[lindex $doings $n]\r" exp_continue } -re {<.+> .*$} { exp_continue } timeout { set n [expr {int(rand() * [llength $complaints])}] send "[lindex $complaints $n]\r" exp_continue } } .