Posted to tcl by tockitj at Wed Jul 18 14:33:08 GMT 2007view raw

  1. #!/usr/bin/expect
  2. spawn socat - TCP4:irc.freenode.org:6667
  3. set NICK($spawn_id) [ string map "%RAND [expr int(10000000 + rand()*89999999)]" Guest_%RAND ]
  4. lappend SPAWNS $spawn_id
  5. set timeout -1
  6.  
  7. expect {
  8. -i $SPAWNS
  9. "NOTICE AUTH :" {
  10. send -i $expect_out(spawn_id) "USER A B C D\n"
  11. send -i $expect_out(spawn_id) "NICK $NICK($expect_out(spawn_id))\n"
  12. exp_continue
  13. }
  14. "VERSION" {
  15. send "JOIN #test_bot\n"
  16. exp_continue
  17. }
  18. -nocase -re "\n:\[^ \n\]* PRIVMSG (\[^ \n\]*) :!spawns*\r\r" {
  19. send -i $expect_out(spawn_id) "PRIVMSG $expect_out(1,string) :spawns $SPAWNS\n"
  20. exp_continue
  21. }
  22. -nocase -re "PING (\[^\n\r\]*)\r\r" {
  23. send -i $expect_out(spawn_id) "PONG $expect_out(1,string)\n"
  24. exp_continue
  25. }
  26. -nocase -re "\n:(\[^\n\r!\]*)!(\[^@\n\]*)@(\[^ \n\]*) NICK :(\[^\r\n \]*)" {
  27. if { [ string compare $expect_out(1,string) $NICK($expect_out(spawn_id)) ] == 0 } {
  28. set NICK($expect_out(spawn_id)) $expect_out(4,string)
  29. }
  30. exp_continue
  31. }
  32. -nocase -re "\n:tockitj!~?(\[^@\n\r\]*)@(\[^ \n\r\]*) PRIVMSG (\[^ \n\r\]*) :!bot *(\[^:\n\r\]*): *(\[^\r\n\]*)\r\r" {
  33. if { [ string first $NICK($expect_out(spawn_id)) $expect_out(4,string) ] != -1 } {
  34. set COMMAND [ string map "%BOT $NICK($expect_out(spawn_id))" $expect_out(5,string) ]
  35. send -i $expect_out(spawn_id) "$COMMAND\n"
  36. }
  37. exp_continue
  38. }
  39. -nocase -re "\n:(\[^!\n\r\]*)!~?(\[^@\r\n\]*)@(\[^ \r\n\]*) PRIVMSG (\[^ \r\n\]*) \: *\!echo (\[^\r\n\]*)\r\r" {
  40. send -i $expect_out(spawn_id) "PRIVMSG $expect_out(4,string) :$expect_out(5,string)\n"
  41. exp_continue
  42. }
  43. -nocase -re "\n:tockitj!~?(\[^@\n\]*)@(\[^ \n\]*) PRIVMSG (\[^ \n\]*) :!clone\r\r" {
  44. spawn socat - TCP4:irc.freenode.org:6667
  45. lappend SPAWNS $spawn_id
  46. set NICK($spawn_id) [ string map "%RAND [expr int(10000000 + rand()*89999999)]" Guest_%RAND ]
  47. set timeout -1
  48. exp_continue
  49. }
  50. }
  51. puts "\n*** DONE *** "
  52.