mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
cric help #222644 28/06/10 03:25 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
hey i need help
cric commentary Snippet

when they commentry will appear on website right at that time it will also post in the my server

here is my commentary script
commentary Snippet mode by hawkee < Jethro_>
i just edit
Code:
on *:playend:$iif($exists(crickcommentary.txt),.remove crickcommentary.txt)
menu menubar,channel,status,nicklist {
  -
  Enable Cric-Commentary {
    autocrickon
    echo 4 -a *** Please Wait a Few Seconds While I Get You the Info...
  }
}
on $*:text:/^[!@.]startmatch$/iS:#:{
  if !%f { inc -u5 %f
    set -u10 %ccrick # | autocrickon
    msg # 4*** Please Wait a Few Seconds While I Get You the Info...
  }
}
on *:sockclose:crickcom:{
  if !$isfile(crickcommentary.txt) {
    $iif(%ccrick,msg $v1,echo 4 -a) 4*** Sorry, No Cricket Match Found on $date $time ***
  }
  else { $sock(crickcom).mark }
}
on *:sockopen:crickcom:{
  var %crickcom sockwrite -n crickcom
  %crickcom GET $+(/score6M691.html) HTTP/1.1
  %crickcom Host: $sock(crickcom).addr $+ $str($crlf,2)
}
on *:sockread:crickcom:{
  var %crickcom | sockread -fn %crickcom
  if $regex(%crickcom,/\S+\-\S+\:\ssmall;">(.*?)</div>/i) {
    write crickcommentary.txt $regsubex($+(Announcement:,$&
      $chr(32),$regml(1)),/<[^>]*>/g,)
  }
  elseif $regex(%crickcom,/<strong>(over)\s(\d+\.\d+)\:(.*)</div>/i) {
    write crickcommentary.txt $single($+(12 $+ $regml(1),$chr(32),$chr(3),05,$&
      $regml(2),$chr(3),$chr(32),:,$chr(32),$regsubex($regml(3),/<[^>]*>/g,)))
    $iif(<div style="clear:both"></div> isin %crickcom,sockclose crickcom)
  }
}
alias -l autocrickon {
  $iif($isfile(crickcommentary.txt),write -c crickcommentary.txt)
  sock $+ $iif($sock(crickcom),close,open) crickcom mathrubhumi.cricfeeds.com 80
  sockmark crickcom .play # crickcommentary.txt 2000
}
alias -l single { return $regsubex($1,/(single)/ig,$+($chr(3),04,\1)) }

Re: cric help [Re: EvilHeart] #222658 28/06/10 09:04 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
bump

Re: cric help [Re: EvilHeart] #222669 29/06/10 07:49 AM
Joined: Aug 2006
Posts: 183
T
Thrull Offline
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Saying "I need help" and then not telling us what you need help with or what you want the script to do or what the error in the script is doesn't usually go very far.

So, if you'd like help, please tell us what the issue is.


Yar
Re: cric help [Re: EvilHeart] #222679 29/06/10 04:00 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
As a side note, this forum doesn't officially allow bumping of topics, and even on the sites that do allow it, you usually have to wait a few days. On Hawkee, for example, you have to wait 5 days, not the (roughly) 6 hours you did.

Re: cric help [Re: Thrull] #222680 29/06/10 05:11 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
i want is that when the website ll be updated ..it will instantly post the updates on my server

Re: cric help [Re: EvilHeart] #223134 15/07/10 11:40 AM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
soo nobody help me? :((

Re: cric help [Re: EvilHeart] #223158 16/07/10 02:07 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You have to be more precise.
- Are the new lines at "Filtered commentary" added at the top or at the bottom of that box?
- What do you mean with "post the updates on my server"? Msg new commentaries to a specific channel, or display them locally, the way they show if you use the popup menu?
- Which time interval for the automated update-check do you have in mind? You wrote "right at that time"... would "every 2 minutes" suffice? (I don't know how expeditiously it has to be - a shorter interval will for sure produce more overhead)
- Do you want the "startmatch" trigger to play only new lines, or keep playing the complete data?

Last edited by Horstl; 16/07/10 02:10 AM.
Re: cric help [Re: Horstl] #223162 16/07/10 09:28 AM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
i want instant post of commentaries...and the Filtered commentary added at the top of the box and yes i would like have a trigger

and about the automatic update...its like after the match starts it should post the updates after every 2seconds

now Australia vs Pakistan match is going to start.. should i change it to
%crickcom GET $+(/score6M691.html) HTTP/1.1
to
%crickcom GET $+(/score6M722.html) HTTP/1.1

Last edited by EvilHeart; 16/07/10 09:38 AM.
Re: cric help [Re: EvilHeart] #223177 16/07/10 11:27 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hope I got you right... ...hope you get my comments smile
I don't see the use of that !startmatch trigger though, as the users cannot request info 'bout different matches (as yet), only the match you did set. The local ticker should work, and gets you started for whatever plans you might have to expand the script in the future.

Code:
; added new menu item to set the match ID %crickid
; added new menu item to start/stop offline timer "crick" (= new ticker)
; renamed command "autocrickon" to "crick", added "type" (last/all) and "target" (output location) parameter to the "crick" command 
menu menubar,channel,status {
  -
  Cric-Commentary
  .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 *** Match ID changed to: %crickid
  }

  .$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 10 crick last status window)
    echo 4 -ag *** Ticker for Match ID %crickid $iif($timer(crick),started,stopped)
  }
  .$iif(%crickid,Show ALL comments now) : {
    crick all status window
    echo 4 -ag *** Please Wait a Few Seconds While I Get You the Info...
  }
}

; "type" and "target" parameters are now sent to command "crick" (and later stored in sockmark), I thus removed the %ccrick global variable 
on $*:text:/^[!@.]startmatch$/iS:#:{
  if (!%crickflood) {
    inc -eu5 %crickflood
    crick all #
    msg # 4 *** Please Wait a Few Seconds While I Get You the Info...
  }
}

; always closes open crick socket
; sockmark now contains "type" and "target" parameter (target parameter allows fast/safe playback to status window/unjoined channels - for my tests in the first place)
alias -l crick {
  if ($sock(crickcom)) { sockclose $v1 }
  sockopen crickcom mathrubhumi.cricfeeds.com 80
  sockmark crickcom $+($1,$chr(1),$2-,$chr(1),.play $iif(($me !ison $2-),$iif(($2- == status window),-se,-e $2-) crickcommentary.txt 1,$2- crickcommentary.txt 2000))
}

; uses now match ID "%crickid" as set in the menu
on *:sockopen:crickcom:{
  sockwrite -n $sockname GET $+(/,%crickid,.html) HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr $+ $str($crlf,2)
}

; moved the check for "end of comments" to the top, it was nested inside the last elseif (at that place it didn't trigger at all: "clear:both" is always a new line)
; furthermore, as there are multiple "style="clear:both"" in the source text, I put "<!--end of main-->" to detect "end of comments"
; the "end of comments" check now will also sockclose if "type" is "last" and the last-known comment had been received - so you can show new comments only
; added a line to capture the two opponents of the match for the "full" output - hope you like it :)
; finally, "on sockclose" won't trigger if you close the socket on your side. Output is now triggered by alias "crickclose".
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)
  }
  ; modified last regsubex to remove tab chars as well
  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)
  }
}

; new close/output alias
alias -l crickclose {
  var %s = $1
  tokenize 1 $sock($1).mark
  sockclose %s
  if (!$lines(crickcommentary.txt)) {
    if ($1 == all) { $iif(($me ison $2),msg $v1 4,echo 4 -ag) *** Sorry, No Cricket Match Found on $date $time *** }
  }
  else {
    ; for type "last" it stores the last line (= last comment) into a global var "%cricklast" to track changes
    if ($1 == last) { set %cricklast $read(crickcommentary.txt,n,$lines(crickcommentary.txt)) }
    ; insert "opponents" header-line or at start of single line
    if ($lines(crickcommentary.txt) > 1) { write -il1 crickcommentary.txt $4 }
    else { write -l1 crickcommentary.txt $4 $read(crickcommentary.txt,n.1) }
    ; play command
    $3
  }
}

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

; checking for $filename is imho better than than $exists (another /play request might end while this script is running)
; restarting the ticker timer on playend should account for playback delay
on *:playend: {
  if ($nopath($filename) == crickcommentary.txt) {
    .remove $qt($filename)
    if ($timer(crick)) { .timercrick -o 0 10 crick last status window }
  }
}


Last edited by Horstl; 16/07/10 11:38 PM.
Re: cric help [Re: Horstl] #223191 17/07/10 03:44 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
Soo Niceee
Thanks Brother Thanks You Soo Muchh

Re: cric help [Re: Horstl] #223192 17/07/10 03:50 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
Error
Code:
* /write: error updating 'C:\MymIRC\crickcommentary.txt' (line 64, crickcommentary.mrc)
-
* /write: error updating 'C:\MymIRC\crickcommentary.txt' (line 64, crickcommentary.mrc)
-
* /write: error updating 'C:\MymIRC\crickcommentary.txt' (line 64, crickcommentary.mrc)
-
* /write: error updating 'C:\MymIRC\crickcommentary.txt' (line 80, crickcommentary.mrc)
-

Re: cric help [Re: EvilHeart] #223199 17/07/10 09:23 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I didn't manage to reproduce these errors. Can you provide a step-by-step procedure/example please?

Re: cric help [Re: Horstl] #223385 22/07/10 02:50 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
everything is ok. it also updates status but this is not updating in the channel... pls can u make it channel system

Re: cric help [Re: EvilHeart] #223398 23/07/10 01:23 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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.
Re: cric help [Re: Horstl] #223399 23/07/10 01:45 AM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
Thanks Bro u Rock laugh

Re: cric help [Re: Horstl] #223404 23/07/10 08:13 AM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
is it possible to change the link for example mathrubhumi.cricfeeds.com to card.cricket.timesofindia.indiatimes.com/commentary.cms?matchid=1056

and it updates will post there

mathrubhumi.cricfeeds.com commentary is not showing the total score .. it only posts the commentary.. it will be better if you can change it..it will whois batting and who is bowling and what is total score..

Re: cric help [Re: EvilHeart] #223410 23/07/10 12:28 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
<head>*sigh*</head>

That page is somewhat more tricky - The barely tested version below should work, however, I had to disable the <match ID> parameter for the !crick trigger.

Note that the new page does not "update" as often as the other one - new lines tend to appear in "blocks". I added timer pause/resume to account for the time playing these "blocks" to a channel will take.

Also note that there are three lines per comment on the page, I condensed them to two lines in the output. This means the text formatting is a kind of clutter - you probably have to live with what I've picked :P

Finally - and no offense - instead of asking time and again for major changes, try to pre-establish a clear idea in the future please, it saves a lot of time. Also try to modify a script on your own first - I'm pretty sure many of the users here are more willing to assist with a specific problem rather a general (re)write.

Code:
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 15 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 -sg *** Please wait a few seconds while I get you the info...
  }
  .-
  .Set match ID $iif(%crickid,$+([current,$chr(58) $v1,])) : {
    set %crickid $$regsubex($input(Enter numerical match ID (e.g. 1056):,eog,Set cricket match ID,%crickid),/\D/g,)
    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 $!
  }
}

; disabled query for <matchID> parameter, as it's glitchy with the new website
; I didn't have the time to take a look at this - maybe you don't need the feature at all.
; on $*:text:/^[!@.]crick ?(\S+)?$/iS:#: {
on $*:text:/^[!@.]crick$/iS:#: {
  if ((!$hget(crickflood,0).item) && (!$timer(crick).pause)) {
    hadd -mu5 crickflood flood
    crick all # $regsubex($regml(1),/\D/g,)
  }
}

alias -l crick {
  if ($sock(crickcom)) { sockclose $v1 }
  sockopen crickcom card.cricket.timesofindia.indiatimes.com 80
  sockmark crickcom $+($1,$chr(1),$2,$chr(1),$iif($3-,$v1,%crickid))
}

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

on *:sockread:crickcom: {
  var %r
  sockread -fn %r

  ; span
  if ($regex(%r,/^<div><span>([\d.]+)<\/span><\/div>$/)) { set -eu10 %crickspan $regml(1) }

  ; "x to y", description, scored runs, total score
  ; checking for "new comments" is somewhat tricky: last line is always "runs scored/total score", which may be the same
  ; furthermore, they tend to UPDATE existing comments (ball mph, typos, whatever) - means, the script wouldn't be able to recognize a modified description as "known" but
  ; replay all comments. the script now checks whether the 2nd last line is a "span" line (and not e.g. a "result" or "header"), to use that span Nr as a "last known" marker
  ; $regml(1) = "bat/bowl", $regml(2) = description, $regml(3) = scored runs, $regml(4) = total score
  elseif ($regex(%r,/^<div class="wth"><span>([^<]+)<\/span><br> ([^<]+)<br>(\S+) ?run.+scored.+Total Score: ([^<]+)<\/div>$/)) {
    var %t2 = $regml(2)
    var %t1 = $+($chr(2), %crickspan $str($chr(15) $chr(32),4) $chr(31), $regml(1),$str($chr(15) $chr(32),5) Scored: $iif(($regml(3) == No),0,$v1) $chr(40),$regml(4),$chr(41))
    if ($gettok($sock($sockname).mark,1,1) == last) && (%crickspan == %cricklast) { crickclose $sockname }
    else { write -il1 crickcommentary.txt %t1 $+ $crlf $+ %t2 }
  }

  ; result (over)
  elseif ($regex(%r,/^<p><strong>([^<]+)<\/strong><\/p>$/)) {
    var %t = 04 $+ $regml(1)
    $iif(($gettok($sock($sockname).mark,1,1) == last) && (%t == %cricklast),crickclose $sockname,write -il1 crickcommentary.txt %t)
  }

  ; misc 
  elseif ($regex(%r,/^<p>([^<]+)</p>$)) {
    $iif(($gettok($sock($sockname).mark,1,1) == last) && ($regml(1) == %cricklast),crickclose $sockname,write -il1 crickcommentary.txt $regml(1)) 
  }

  ; opponents
  elseif ($regex(%r,/^<h2><i><a href=[^>]+>([^>]+)<\/a><\/i><\/h2>.+<h2><i><a href=[^>]+>([^>]+)<\/a><\/i><\/h2>$/)) {
    sockmark $sockname $+($sock($sockname).mark,$chr(1),$regml(1) vs $regml(2))
  }

  ; end of comments (close socket)
  elseif (%r == <td class="rtclm" valign="top">) { crickclose $sockname }
}

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) {
      var %l1 = $read(%f,n,$lines(%f)), %l2 = $read(%f,n,$calc($lines(%f) -1))
      set %cricklast $iif(($gettok($strip(%l2),1,32) isnum),$v1,%l1)
    }
    if ($4) {
      if ($lines(%f) > 2) { write -il1 %f 04 $+ $4 }
      else { write -l1 %f 04 $+ $4 - $read(%f,n,1) }
    }
    if ($1 == all) {
      if ($me !ison $2) { .play $iif(($v2 == status),-pse,-pe $v1) %f 0 }
      else {
        .play -m3 $2 %f 1500
        if ($timer(crick)) { .timercrick -p }
      }
    }
    elseif ($1 == last) {
      .play -pse %f 0
      if ($me ison %crickchan) {
        .play -m3 $v2 %f 1500
        if ($timer(crick)) { .timercrick -p }
      }
    }
  }
}

on *:sockclose:crickcom: { crickclose $sockname }

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).pause) { .timercrick -r }
  }
}

on *:unload: { unset %crick* }


Edit: added "misc"

Last edited by Horstl; 23/07/10 12:44 PM.
Re: cric help [Re: Horstl] #223413 23/07/10 07:02 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41
sorry i didn't thought that it is possible to do..but u made it thanks.. but plz make it one like > 15.2 Shane Watson to Azhar Ali Scored: 0 (67/1) Played to the point region by Ali. No run..

this is not working like before
it is posting but not regularly
not in time even
and thanks again

Re: cric help [Re: EvilHeart] #223448 25/07/10 12:15 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: EvilHeart
this is not working like before
it is posting but not regularly
not in time even
That's what I meant with: "the new page does not 'update' as often [...] as the other one - new lines tend to appear in 'blocks'".
On that websie, comments don't appear one by one but in chunks. I can do nothing about it. It looks like the website is updated every minute (or so - rather more infrequent); the script does query the website every 20 seconds. Exactly for that reason I increased the interval to 20s: a shorter query interval won't help you with it but produce gratuitous overhead.

Originally Posted By: EvilHeart
but plz make it one like > 15.2 Shane Watson to Azhar Ali Scored: 0 (67/1) Played to the point region by Ali. No run..
I can do that, but it will increase the risk of lines "too long" to be sent into a channel, of lines truncated or split at odd positions. (Sometimes the part "Played to the point region by Ali. No run.." is very long.)

Let me know if you want the single-lined output formatting for the new website nevertheless.

Last edited by Horstl; 25/07/10 12:18 AM.
Re: cric help [Re: Horstl] #231645 26/04/11 05:24 PM
Joined: Mar 2007
Posts: 41
E
EvilHeart Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2007
Posts: 41

Last edited by EvilHeart; 26/04/11 05:25 PM.
Page 1 of 2 1 2