The new menu item "set tracking channel" allows you to msg new comments to a channel - given that you've joined that chan and the ticker is enabled.
"!startmatch" is now "!crick" and you can now use "!crick <match ID>" as well.
Note that I added only a basic sollution - it's e.g. not capable of a multi-channel / multi-network setup. I twiddled with the remaining code here and there a bit, but it's clumsy (and getting worse more and more)... be that as it may laugh

Code:
; added menu item "set tracking channel" - ticker will now 1) always play to the status window 2) play to tracking channel, if possible
menu menubar,channel,status {
  -
  Cricket-Ticker
  .$iif(!%crickid,$style(2) -- you have to set a match ID first --) : noop
  .$iif(%crickid,$iif($timer(crick),$style(1) Ticker $+ $chr(58) enabled,Ticker $+ $chr(58) disabled))
  ..$iif($timer(crick),disable,enable) {
    .timercrick $iif($timer(crick),off,-o 0 20 crick last status)
    echo 4 -ag *** Ticker for match ID %crickid $iif($timer(crick),started,stopped)
  }
  .$iif(%crickid,Show all comments now) : {
    crick all status
    echo 4 -ag *** Please wait a few seconds while I get you the info...
  }
  .-
  .Set match ID $iif(%crickid,$+([current,$chr(58) $v1,])) : {
    set %crickid $$gettok($gettok($input(Enter match ID (e.g. score6M691):,eog,Set cricket match ID,%crickid),-1,47),1,46)
    echo 4 -ag *** Cricket-Ticker match ID changed to: %crickid
  }
  .$iif(%crickid,Set tracking channel $+([current,$chr(58) $iif(%crickchan,$v1,none),])) : {
    noop $input(Enter channel name:,eog,Set ticker tracking channel,%crickchan)
    echo 4 -ag *** Ticker is $iif($!,$iif(($v1 != %crickchan),now) tracked at: $v1,not tracked $iif((%crickchan),anymore))
    set %crickchan $!
  }
}

; renamed trigger command "!startmatch" to "!crick"
; extended trigger command "!crick": if used without parameter, displays results for match ID as set in the menu
; if used with parameter <match ID>, displays the results for <match ID> respectively
; flood check is now hash instead of global var (gvars persist e.g. in case of a crash)
on $*:text:/^[!@.]crick ?(\S+)?$/iS:#: {
  if (!$hget(crickflood,0).item) {
    hadd -mu5 crickflood flood
    crick all # $regsubex($regml(1),/\W/g,)
    msg # 4 *** Please wait a few seconds while I get the info...
  }
}

; removed play command from sockmark, output method is now processed at alias crickclose
; match ID is now part of sockmark
alias -l crick {
  if ($sock(crickcom)) { sockclose $v1 }
  sockopen crickcom mathrubhumi.cricfeeds.com 80
  sockmark crickcom $+($1,$chr(1),$2,$chr(1),$iif($3-,$v1,%crickid))
}

on *:sockopen:crickcom: {
  sockwrite -n $sockname GET $+(/,$gettok($sock($sockname).mark,3-,1),.html) HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr $+ $str($crlf,2)
}

on *:sockread:crickcom: {
  var %read
  sockread -fn %read
  if (%read == </div> <!--end of main--></div>) { crickclose $sockname }
  elseif ($regex(%read,/<div class="cf_np_column2"><span class="cf_underlin">([^<]+)<br \/><\/span>/)) {
    sockmark $sockname $+($sock($sockname).mark,$chr(1),$regml(1))
  }
  elseif ($regex(%read,/\S+\-\S+\:\ssmall;">(.*?)</div>/i)) {
    var %t = $regsubex($+(Announcement:,$chr(32),$regml(1)),/<[^>]*>/g,)
    $iif(($gettok($sock($sockname).mark,1,1) == last) && (%t == %cricklast),crickclose $sockname,write -il1 crickcommentary.txt %t)
  }
  elseif ($regex(%read,/<strong>(over)\s(\d+\.\d+)\:(.*)</div>/i)) {
    var %t = $single($+(12 $+ $regml(1),$chr(32),$chr(3),05,$regml(2),$chr(3),$chr(32),:,$chr(32),$regsubex($regml(3),/(?:<[^>]*>|\t)/g,)))
    $iif(($gettok($sock($sockname).mark,1,1) == last) && (%t == %cricklast),crickclose $sockname,write -il1 crickcommentary.txt %t)
  }
}

; output command is now processed here
; added -p "priority" switch for local playbacks and -m3 "limit" switch for channel playbacks
; fixed typo "$read(crickcommentary.txt,n.1)" - has to be: ... ",n,1)"
; added check for existing opponents string $4
alias -l crickclose {
  var %s = $1, %f = crickcommentary.txt
  tokenize 1 $sock($1).mark
  sockclose %s
  if (!$lines(%f)) {
    if ($1 == all) { $iif(($me ison $2),msg $v2 4,echo 4 -ag) *** Sorry, no data found for match ID $qt($3) }
  }
  else {
    if ($1 == last) { set %cricklast $read(%f,n,$lines(%f)) }
    if ($4) {
      if ($lines(%f) > 1) { write -il1 %f $4 }
      else { write -l1 %f $4 - $read(%f,n,1) }
    }
    if ($1 == all) { .play  $iif(($me !ison $2),$iif(($v2 == status),-pse,-pe $v1) %f 0,-m3 $v2 %f 1500)) }
    elseif ($1 == last) {
      .play -pse %f 0
      if ($me ison %crickchan) { .play -m3 $v2 %f 1500 }
    }
  }
}

; re-added sockclose event (for "no data found" message)
on *:sockclose:crickcom: { crickclose $sockname }

alias -l single { return $regsubex($1,/(single)/ig,$+($chr(3),04,\1)) }

on *:playend: {
  if ($nopath($filename) == crickcommentary.txt) {
    var %n = 1
    while ($play(%n).fname) {
      if ($v1 == $filename) { return }
      inc %n
    }
    .remove $qt($filename)
    if ($timer(crick)) { .timercrick -o 0 20 crick last status }
  }
}

on *:unload: { unset %crick* }

Last edited by Horstl; 23/07/10 01:32 AM.