Wollte Knobie haben, evtl. braucht ihn ja noch jemand
;live-ticker
alias ticker {
!var %@ = @live-ticker,%f = ticker.xml,%t = $md5($ctime) $+ .txt
if (!$window(%@)) {
!window -dek0z @live-ticker
!.timerticker 0 30 ticker
}
!editbox %@ Refreshing Ticker...
!var %url = http://ticker.rp-online.de/zweiteliga/xml/index.xml
!noop $download(%f, GET, %url, 2)
!var %l = $lines(%f),%i = 0
!editbox %@ Parsing XML...
!var %s = 1
while ($read(%f,rw,*<match matchid="*" team1="*" team2="*" score1="*" score2="*" status="*" />*,%s)) {
!var %mi = $ifmatch
!var %matches = $regex(%mi,\<match matchid="(.*)" team1="(.*)" team2="(.*)" score1="(.*)" score2="(.*)" status="(.*)" \/\>)
!var %p = 1
while ($len($regml(%p))) {
!var %. = $regml(%p)
if (%p == 1) { !var %mid = %. }
elseif (%p == 2) { !var %match [ $+ [ %mid ] ] %. }
elseif (%p == 3) { %match [ $+ [ %mid ] ] = %match [ $+ [ %mid ] ] vs. %. }
elseif (%p == 4) { %match [ $+ [ %mid ] ] = %match [ $+ [ %mid ] ] ( $+ %. }
elseif (%p == 5) { %match [ $+ [ %mid ] ] = %match [ $+ [ %mid ] ] $+ : $+ %. $+ ) }
;elseif (%p == 6) { %match [ $+ [ %mid ] ] = %match [ $+ [ %mid ] ] - %. }
!inc %p
}
%s = $readn + 1
}
!write -c %t
while ($read(%f,nw,*<event*>*,$readn)) {
!inc %i
!var %o1 = $ifmatch
!var %o2 = $read(%f,n,$calc($readn +1))
!var %mi = $remove($gettok(%o1,2,32),matchid=",">,")
!var %ma = $remove($gettok(%o1,3,32),minute=",">,")
!write -il1 %t $iif($len(%ma),Minute %ma $+ ) $iif(%match [ $+ [ %mi ] ],$ifmatch) $replace(%o2,<strong>,,</strong>,,<b>,,</b>,)
}
!editbox %@ Displaying result...
!var %x = $lines(%t)
if ($read(%t,n,%x) == <event>) { !write -dl $+ %x %t }
!loadbuf -rp %@ %t
!editbox %@ Done.
!.remove %t
!.remove %f
}
on *:close:@live-ticker:{ if ($timer(ticker)) { !.timerticker off } }
; download alias
alias download {
var %r = $(|,) return $false, %e = scon -r !echo $color(info) -a $!!download: Error -
if (!$isid) %e this snippet can only be called as an identifier. %r
if ($os isin 9598) %e this snippet requires Windows ME or higher. %r
if ($version < 6) %e this snippet requires mIRC version 6.0 or higher. %r
var %dir = $nofile($1), %file = $nopath($1), %method = $upper($2), %url = $3
var %bit = $4, %headers = $iif($2 == get,$5,$6), %postdata = " $+ $5", %res
if (* !iswm %file) %e you must specify a file to save the data to. %r
if (%file != $mkfn(%file)) %e file %file contains illegal characters. %r
if (* !iswm %dir) %dir = $mircdir
elseif (!$isdir(%dir)) %e no such folder %dir %r
if (!$istok(get head post,$2,32)) %e method can only be GET, HEAD or POST. %r
;if (!$regex(%e,$3,/^\S+\.\S+\.\S+$/)) %e you didn't specify an url to download from. %r
if ($2 != head) {
if ($4 !isnum 1-3) %e bitmask should be a digit in range 1-3. %r
if ($2 == post) && (* !iswm $5) %e you didn't specify any post data. %r
if (%headers) && (!$regsub(%e,%headers,/(\S+?): (.+?)(?=\s?\n|$)/g,"\1" $chr(44) "\2",%headers)) {
%e bad header syntax. Correct -> Label: value seperated by $!!lf's %r
}
}
var %file = $+(",%dir,%file,"), %id = $+(@download,$ticks,$r(1111,9999),.vbs), %a = aline %id
if (http://* !iswm $3) %url = http:// $+ $3
.comopen %id wscript.shell
if ($comerr) %e could not open Wscript.Shell. %r
write -c %file
window -h %id
%a on error resume next
%a sub quit $lf set http = nothing : set ado = nothing : wscript.quit $lf end sub
%a sub errmsg
%a set fso = createobject("scripting.filesystemobject")
%a set file = fso.createtextfile( %file ,true)
%a file.write("Err number: " & err.number & " = " & err.description) : file.close
%a set fso = nothing
%a quit
%a end sub
%a arr = array("winhttp.winhttprequest.5.1","winhttp.winhttprequest","msxml2.serverxmlhttp","microsoft.xmlhttp")
%a i = 0 $lf while i < 4 and not isobject(http) : set http = createobject(arr(i)) : i = i + 1 : wend
%a if not isobject(http) then errmsg
%a err.clear
%a http.open $+(",%method,") , $+(",%url,") ,false
%a http.setrequestheader "User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
if (%headers) { tokenize 10 %headers | scon -r %a http.setrequestheader $* }
if (%method == post) {
%a http.setrequestheader "Content-Type","application/x-www-form-urlencoded"
%a http.send %postdata
}
else %a http.send
%a if err then errmsg
%a set ado = createobject("adodb.stream")
%a if not isobject(ado) then errmsg
%a ado.open
if (%bit != 2) {
%a ado.type = 2 : ado.charset = "ascii"
%a ado.writetext "HTTP/1.1 " & http.status & " " & http.statustext,1
%a ado.writetext http.getallresponseheaders,1 : ado.position = 0
}
if (%bit != 1) %a ado.type = 1 : ado.read : ado.write http.responsebody
%a ado.savetofile %file ,2 : ado.close : quit
savebuf %id %id
close -@ %id
.comclose %id $com(%id,run,1,bstr*,cscript.exe %id,uint,0,bool,true)
.remove %id
%res = $read(%file,t,1)
if (Err number:*=* iswm %res) || (!$file(%file)) %e $iif(%res,%res,no data could be retrieved) - %url %r
return $true
:error
if ($com(%id)) .comclose %id
if ($isfile(%id)) .remove %id
if ($window(%id)) close -@ %id
return $false
}