This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

livescore tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
h
heroes
Voice
Posts: 17
Joined: Sat Dec 01, 2007 5:34 am
Contact:

livescore tcl

Post by heroes »

any idea about soccer score tcl??
ehmm...
can auto post to channel the update score.
take the score from livescore.com
or other web.
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Re: livescore tcl

Post by eXtremer »

heroes wrote:any idea about soccer score tcl??
ehmm...
can auto post to channel the update score.
take the score from livescore.com
or other web.
hmmm interesting...
m
moff
Voice
Posts: 27
Joined: Thu Jul 24, 2008 9:24 pm

Post by moff »

Code: Select all

################################################################################
#                                                                              #
#      :::[  T h e   R u s s i a n   E g g d r o p  R e s o u r c e  ]:::      #
#    ____                __                                                    #
#   / __/___ _ ___ _ ___/ /____ ___   ___      ___   ____ ___ _     ____ __ __ #
#  / _/ / _ `// _ `// _  // __// _ \ / _ \    / _ \ / __// _ `/    / __// // / #
# /___/ \_, / \_, / \_,_//_/   \___// .__/ __ \___//_/   \_, / __ /_/   \___/  #
#      /___/ /___/                 /_/    /_/           /___/ /_/              #
#                                                                              #
################################################################################
#                                                                              #
# livescore.tcl 2.0                                                            #
#                                                                              #
# Author: Stream@Rusnet <stream@eggdrop.org.ru>                                #
#                                                                              #
# Official support: irc.eggdrop.org.ru @ #eggdrop                              #
#                                                                              #
################################################################################

if {![info exists egglib(ver)]} {
	putlog "************************************************"
	putlog "             egglib_pub NOT FOUND !"
	putlog "   Download last version of egglib_pub here:"
	putlog "  http://eggdrop.org.ru/scripts/egglib_pub.zip"
	putlog "************************************************"
	die
}

if {[expr {$egglib(ver) < 1.4}]} {
	putlog "************************************************"
	putlog "    YOUR VERSION OF egglib_pub IS TOO OLD !"
	putlog "   Download last version of egglib_pub here:"
	putlog "  http://eggdrop.org.ru/scripts/egglib_pub.zip"
	putlog "************************************************"
	putlog " version installed : $egglib(ver)"
	putlog " version required: 1.4"
	die
}

#################################################

namespace eval ls {}

setudef flag nopubls

#################################################

bind pub - !ls		::ls::pub_ls
bind pub - !score	::ls::pub_ls
bind pub - !livescore	::ls::pub_ls
bind msg - !ls		::ls::msg_ls
bind msg - !score	::ls::msg_ls
bind msg - !livescore	::ls::msg_ls

#################################################

foreach p [array names ls *] { catch {unset ls($p)} }

#max results per public query
set ls(maxres)		10

set ls(timeout) 	20
set ls(debug) 		1

set ls(use_proxy) 	0
set ls(proxy_host) 	"proxy1.bezeqint.net"
set ls(proxy_port) 	3128

#################################################
##### DON'T CHANGE ANYTHING BELOW THIS LINE #####
#################################################

set ls(ver) 		"2.0"
set ls(authors)		"Stream@RusNet <stream@eggdrop.org.ru>"
set ls(agent)		"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"

#################################################

proc ::ls::pub_ls { nick uhost hand chan args } {
	if {[channel get $chan nopubls]} return
	set args [string tolower [string trim $args]]
	if {[llength [split [lindex $args 0]]] > 1 || [llength [split [lindex $args 0]]] == 0} {set args [split [lindex $args 0]]}
	if {[llength $args] < 1} {::egglib::outn $nick "Use !livescore \[-country\] <search_mask>. Mask can contain '*' and '?', search will be performed in command names and scores."; return}
	::ls::ls $nick $uhost $hand $chan $args
}
proc ::ls::msg_ls { nick uhost hand args } {
	set args [string tolower [string trim $args]]
	if {[llength [split [lindex $args 0]]] > 1 || [llength [split [lindex $args 0]]] == 0} {set args [split [lindex $args 0]]}
	if {[llength $args] < 1} {::egglib::outn $nick "Use !livescore \[-country\] <search_mask>. Mask can contain '*' and '?', search will be performed in command names and scores."; return}
	::ls::ls $nick $uhost $hand $nick $args
}

#################################################

proc ::ls::ls { nick uhost hand chan args } {
 	global ls
	if {[info exists ls(host,$uhost)]} {::egglib::outn $nick "Please wait till last query will be finished..."; return}
	if {[llength [split [lindex $args 0]]] > 1 || [llength [split [lindex $args 0]]] == 0} {set args [split [lindex $args 0]]}

	if {[string range [lindex $args 0] 0 0] == "-"} {
		set country [string range [lindex $args 0] 1 end]
		set mask [lrange $args 1 end]
	} else {
		set country "ukraine"
		set mask $args
	}

	::egglib::log $chan $nick "ls" "$country $mask"
	if {[string range $mask 0 0] != "*"} {set mask "*$mask"}
	if {[string range $mask end end] != "*"} {set mask "$mask\*"}
	set ls(host,$uhost) [list $country $mask]
	set url "http://www.livescore.com/default.dll?page=$country"
	set id [::egglib::http_init "::ls::ls_"]
	if {$ls(use_proxy)} {::egglib::http_set_proxy $id $ls(proxy_host) $ls(proxy_port)}
	::egglib::http_set_timeout $id $ls(timeout)
	::egglib::http_get $id $url [list $nick $chan $uhost]
}

proc ::ls::ls_on_data { id html nick chan uhost } {
	global ls
  	if {$ls(debug)} {putlog "\[ls\] callback executed... analyzing data..."}

  	regsub -all -nocase -- <tr $html \n<tr html
  	#::egglib::writedata "debugls.htm" [list $html]

	foreach line [split $html \n] {
		if {[regexp -nocase -- {<html>.*robots.*refresh.*URL\=(.*?)\".*action\=\"(.*?)\".*value\=\"(.*?)\"} $line garb url posturl sid]} {
			putlog "antibot check found. redirecting to $url & POSTing to $posturl (params sid=$sid)"
			set url "http://www.livescore.com$url"
			set id [::egglib::http_init "::ls::ls1_"]
			if {$ls(use_proxy)} {::egglib::http_set_proxy $id $ls(proxy_host) $ls(proxy_port)}
			::egglib::http_set_timeout $id 1
			::egglib::http_get $id $url [list $nick $chan $uhost]
			set url "http://www.livescore.com$posturl"
			set param "sid=$sid"
			set id [::egglib::http_init "::ls::lspost_"]
			if {$ls(use_proxy)} {::egglib::http_set_proxy $id $ls(proxy_host) $ls(proxy_port)}
			::egglib::http_set_timeout $id $ls(timeout)
			::egglib::http_set_method $id "POST"
			::egglib::http_post $id $url $param [list $nick $chan $uhost]
			break
		}
	}

	if {$ls(debug)} {putlog "\[ls\] html parsed"}
}

proc ::ls::ls_on_error { id nick chan uhost } {
	global ls
	catch {unset ls(host,$uhost)}
	if {$ls(debug)} {putlog "\[ls\] connection timed out"}
	if {$nick == " "} {return}
	::egglib::out $nick $chan "cant connect to livescore.com..."
}

proc ::ls::ls1_on_data { id html nick chan uhost } {
  	::egglib::writedata "debugls1.htm" [list $html]
	if {$ls(debug)} {putlog "\[ls1\] callback executed! Something is wrong..."}
}

proc ::ls::ls1_on_error { id nick chan uhost } {
	global ls
	if {$ls(debug)} {putlog "\[ls1\] connection timed out - OK"}
}

proc ::ls::lspost_on_data { id html nick chan uhost } {
	global ls
  	if {$ls(debug)} {putlog "\[lspost\] callback executed... analyzing data..."}

  	#::egglib::writedata "debugpost.htm" [list $html]

	set moved 0
	foreach line [split $html \n] {
		if {[string match "HTTP* 302 Object Moved" $line]} {set moved 1
		} elseif {$moved == 1} {
			if {[regexp -nocase -- {^Location\:\ (.*?)$} $line garb url]} {
				if {$ls(debug)} {putlog "recieved HTTP 302 Object Moved, new location: $url"}
				set url "http://www.livescore.com$url"
				set id [::egglib::http_init "::ls::ls2_"]
				if {$ls(use_proxy)} {::egglib::http_set_proxy $id $ls(proxy_host) $ls(proxy_port)}
				::egglib::http_set_timeout $id $ls(timeout)
				::egglib::http_get $id $url [list $nick $chan $uhost]
			}
		}
	}
	if {$ls(debug)} {putlog "\[lspost]: html parsed"}
}

proc ::ls::lspost_on_error { id nick chan uhost } {
	global ls
	catch {unset ls(host,$uhost)}
	if {$ls(debug)} {putlog "\[lspost\] connection timed out"}
	if {$nick == " "} {return}
	::egglib::out $nick $chan "cant connect to livescore.com..."
}

proc ::ls::ls2_on_data { id html nick chan uhost } {
	global ls
	catch {
		set country [lindex $ls(host,$uhost) 0]
		set mask [lrange $ls(host,$uhost) 1 end]
		#putlog "country = $country , mask = $mask"
		unset ls(host,$uhost)
	}
	if {$ls(debug)} {putlog "\[ls2\] callback executed... analyzing data..."}

	regsub -all -nocase -- <tr $html \n<tr html
	#::egglib::writedata "debugls2.htm" [list $html]

	if {$nick != $chan} {set nick ""}

	set cfound 0
	set cts ""
	set title ""
	set tshown 0
	set timedate ""
	set tdshown 0
	set resshown 0
	set restotal 0
	foreach line [split $html \n] {
		if {$cfound == 0} {
			if {[regexp -nocase -- {<tr><td.*><img.*name\=\"i(.*)\"\ alt.*><a\ href\=\"/default.dll\?page\=([a-z]+)\"\ on.*>(.*?)</a></td></tr>} $line garb cnum page ctr]} {
				if {$cnum > 4} {
					if {$cts == ""} {set cts $page} else {set cts "$cts\, $page"}
					if {$page == $country} {set cfound 1}
				}
			} elseif {[regexp -nocase -- {<tr><td.*><img.*name\=\"i(.*)\"\ alt.*><a\ href\=\"/default.dll\?page\=([a-z]+)\"\ class\=\"selected\">(.*?)</a></td></tr>} $line garb cnum page ctr]} {
				if {$cnum > 4} {
					if {$cts == ""} {set cts $page} else {set cts "$cts\, $page"}
					if {$page == $country} {set cfound 1}
				}
			}
			if {[string match "<tr><td colspan=\"4\" height=\"1\"></td></tr>" $line] && $cfound == 0} {
				::egglib::out $nick $chan "Available values: $cts"
				return
			}
		}
		if {[regexp -nocase -- {^<tr.*><td\ class\=\"title\".*>\ \;<b>(.*?)</b>\ \-\ (.*?)</td></tr>} $line garb country league]} {
			set title "\002$country\002 - $league"
			set tshown 0
			set tdshown 0
			set timedate ""
			#putlog "title = $title"
			continue
		} elseif {[regexp -nocase -- {^<tr.*><td.*>\ \;(.*?)</td><td.*>(.*?)\ \;</td></tr>$} $line garb tm dt]} {
			if {$tm == ""} {set timedate $dt} else {set timedate "$tm, $dt"}
			set tdshown 0
			#putlog "timedate = $timedate"
			continue
		} elseif {![regexp -nocase -- {<tr.*><td.*>\ \;(.*?)</td><td.*>(.*?)</td>.*<a.*>(.*?)</a></td><td.*>(.*?)</td>} $line garb state team1 score team2]} {
			if {![regexp -nocase -- {<tr.*><td.*>\ \;(.*?)</td><td.*>(.*?)</td><td.*>(.*?)</td><td.*>(.*?)</td>} $line garb state team1 score team2]} {continue}
		}
		regsub -nocase {^(.*?)\-(.*?)$} $score {\1-\2} score
		set res "($state) $team1 $score $team2"
		if {[string match $mask [string tolower $res]]} {
			#putlog "res = $res"
			incr restotal
			if {$restotal > $ls(maxres) && $nick != $chan} {continue}
			incr resshown
			if {$tshown == 0} {
				::egglib::out $nick $chan $title
				set tshown 1
			}
			if {$tdshown == 0} {
				::egglib::out $nick $chan $timedate
				set tdshown 1
			}
			::egglib::out $nick $chan $res
		}
	}
	if {$ls(debug)} {putlog "\[ls2\] html parsed"}
	if {$resshown < $restotal} {::egglib::out $nick $chan "Showed $resshown from $restotal (full list will be available by command to PM)."}
}

proc ::ls::ls2_on_error { id nick chan uhost } {
	global ls
	catch {unset ls(host,$uhost)}
	if {$ls(debug)} {putlog "\[ls2\] connection timed out"}
	if {$nick == " "} {return}
	::egglib::out $nick $chan "cant connect to livescore.com..."
}

putlog "livescore.tcl v$ls(ver) by $ls(authors) loaded"
found this one, but i dont get output
g
guest
Halfop
Posts: 52
Joined: Mon Jan 19, 2004 4:15 pm

Post by guest »

any chance of getting a script that does other sports like nba mlb nfl
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

some update for this script? actually no found.

thanks.
B
Behemoth
Voice
Posts: 20
Joined: Mon May 19, 2008 7:23 am
Location: Mauritius
Contact:

livescore.tcl

Post by Behemoth »

hello..
can the above posted script ( livescore.tcl ) be translated in English plz ?


thnkx
Http://optix-pro.labrute.fr/
Http://ircaz.fr/

Losers Always Whine About Their Best, But Winners Go Home And F*** The Prom Queen!
D
DaRkOoO
Halfop
Posts: 67
Joined: Sat Sep 27, 2008 7:27 am

Post by DaRkOoO »

It doesn't work..
T
Tumpero
Voice
Posts: 2
Joined: Fri Jul 04, 2008 5:11 pm

Post by Tumpero »

Any luck for this?
Post Reply