# Server ip address/hostname
# List ip to challange
rhost set [list {1} "192.168.0.1" /
                {2} "192.168.0.2" ]

# Server port
# List ports to challange together with similar listed ip above.
rport set [list {1} "27015" /
                {2} "27016" ]

# Rcon password
set rconpass "*******"


#################################################
## Shouldn't need to change anything down here ##
#################################################

set botchan "#channel"
set challenge [challengercon $rhost $rport]

bind pub n|n !challenge rconchallenge

proc rconchallenge {nick ident handle channel argument } {
      global rhost rport challenge
      set challenge [challengercon $rhost $rport]
      putserv "NOTICE $nick :Challenge received"
}

proc myrcon {mycmd} {
  global rhost rport rconpass challenge

  set response [rcon $rhost $rport $challenge "$rconpass" $mycmd]

  if {[regexp {Bad challenge.} $response all] || [regexp {No challenge for your address.} $response all]} {
      set challenge [challengercon $rhost $rport]
      set response [rcon $rhost $rport $challenge "$rconpass" $mycmd]
  }

  return $response
}