Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# !table channels
set table_chans {#channel1 #channel2}
#######################################################################
bind pub -|- !table show_table
package require http
proc get_table { } {
set http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
set http_token [http::config -useragent $http_uagent]
if {[catch {set http_token [::http::geturl "http://www.skysports.com/football/league/0,19540,11660,00.html" -timeout 10000]}]} {
return "error"
} {
return [http::data $http_token]
}
}
proc show_table { nick uhost hand chan arg } {
global table_chans
if {[lsearch $table_chans $chan] == -1} {
return
}
set poss [lindex [split $arg] 0]
if {$poss != ""} {
if {[regexp {^[0-9]+$} $poss]} {
set start_pos $poss
set end_pos $poss
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :max is 20, sorry"
return
}
}
if {[regexp {^[0-9]+\-[0-9]+$} $poss]} {
set split_pos [split $poss "-"]
set start_pos [lindex $split_pos 0]
set end_pos [lindex $split_pos 1]
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :max is 20, sorry"
return
}
}
} {
set start_pos 1
set end_pos 20
}
if {$start_pos > $end_pos} {
putquick "PRIVMSG $nick :first argument must be lower than second ie. 1-20, not 20-1"
return
}
set all [get_table]
if {$all == "error"} {
putquick "PRIVMSG $nick :problem with connection, try again later, sorry"
return
}
regsub -all "\n" $all "" all
regsub -all "\t" $all "" all
# some number before team name
regsub -all -nocase {<tr(\s+|[a-zA-Z=\"\- ]+)>\s+<td>(\d+|\-\d+)<\/td>} $all "" all
# team points
regsub -all -nocase {<td>(\d+|\-\d+)<\/td>} $all {<pkt>\1</pkt>} all
# team name, 1st tag
regsub -all -nocase {<td><a\s+href=\"\/football\/team\/0,\d+,\d+,00\.html\">} $all "<team_title>" all
# <team> team name here </team>
regsub -all -nocase {<team_title>([a-zA-Z ]+)</a></td>} $all {<team>\1</team>} all
# new line marks
regsub -all "<team>" $all "\n<team>" all
regsub -all "<\/team>" $all "<team>\n" all
regsub -all "<pkt>" $all "\n<pkt>" all
regsub -all "<\/pkt>" $all "<pkt>\n" all
set team_pos 1
set team_idx 0
set team_list [list]
putquick "PRIVMSG $nick :Pos | Team | P | W | D | L | F | A | GD | PTS"
putquick "PRIVMSG $nick :---------------------------------------------"
# "clean" team names, points
foreach a [split $all "\n"] {
if {[string match *<team>* $a]} {
regsub -all "<team>" $a "" a
regsub -all "<\/team>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {[string match *<pkt>* $a]} {
regsub -all "<pkt>" $a "" a
regsub -all "<\/pkt>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {$team_idx == 9} {
if {($team_pos >= $start_pos) && ($team_pos <= $end_pos)} {
putquick "PRIVMSG $nick :$team_pos|[join $team_list "|"]"
}
set team_list [list]
set team_idx 0
incr team_pos 1
}
}
}
putlog "football-table.tcl ver 0.1 by tomekk loaded"
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# !table channels
set table_chans {#chan #chan2}
#######################################################################
bind pub -|- !table show_table
package require http
proc get_table { } {
set http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
set http_token [http::config -useragent $http_uagent]
if {[catch {set http_token [::http::geturl "http://www.skysports.com/football/league/0,19540,11660,00.html" -timeout 10000]}]} {
return "error"
} {
return [http::data $http_token]
}
}
proc show_table { nick uhost hand chan arg } {
global table_chans
if {[lsearch $table_chans $chan] == -1} {
return
}
set poss [lindex [split $arg] 0]
if {$poss != ""} {
if {[regexp {^[0-9]+$} $poss]} {
set start_pos $poss
set end_pos $poss
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :Sorry $nick The max is 20"
return
}
}
if {[regexp {^[0-9]+\-[0-9]+$} $poss]} {
set split_pos [split $poss "-"]
set start_pos [lindex $split_pos 0]
set end_pos [lindex $split_pos 1]
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :Sorry $nick The max is 20"
return
}
}
} {
set start_pos 1
set end_pos 20
}
if {$start_pos > $end_pos} {
putquick "PRIVMSG $nick :Sorry $nick The first argument must be lower than second ie. 1-20, not 20-1"
return
}
set all [get_table]
if {$all == "error"} {
putquick "PRIVMSG $nick :Sorry $nick Theres a small problem with connection, try again later, Thanks :-)"
return
}
regsub -all "\n" $all "" all
regsub -all "\t" $all "" all
# some number before team name
regsub -all -nocase {<tr(\s+|[a-zA-Z=\"\- ]+)>\s+<td>(\d+|\-\d+)<\/td>} $all " " all
# team points
regsub -all -nocase {<td>(\d+|\-\d+)<\/td>} $all {<pkt>\1</pkt>} all
# team name, 1st tag
regsub -all -nocase {<td><a\s+href=\"\/football\/team\/0,\d+,\d+,00\.html\">} $all "<team_title> " all
# <team> team name here </team>
regsub -all -nocase {<team_title>([a-zA-Z ]+)</a></td>} $all {<team>\1</team>} all
# new line marks
regsub -all "<team>" $all "\n <team> " all
regsub -all "<\/team>" $all "<team>\n" all
regsub -all "<pkt>" $all "\n <pkt> " all
regsub -all "<\/pkt>" $all " <pkt> \n" all
set team_pos 1
set team_idx 0
set team_list [list]
putquick "PRIVMSG $nick :Pos | Team | P | W | D | L | F | A | GD | PTS"
putquick "PRIVMSG $nick :---------------------------------------------"
# "clean" team names, points
foreach a [split $all "\n"] {
if {[string match *<team>* $a]} {
regsub -all "<team>" $a "" a
regsub -all "<\/team>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {[string match *<pkt>* $a]} {
regsub -all "<pkt>" $a "" a
regsub -all "<\/pkt>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {$team_idx == 9} {
if {($team_pos >= $start_pos) && ($team_pos <= $end_pos)} {
putquick "PRIVMSG $nick :$team_pos|[join $team_list "|"]"
putquick "PRIVMSG $nick :---------------------------------------------"
}
set team_list [list]
set team_idx 0
incr team_pos 1
}
}
}
putlog "football-table.tcl ver 0.1 by tomekk loaded"
instead of[10:32:23pm] <FelixBot> Pos | Team | P | W | D | L | F | A | GD | PTS
[10:32:23pm] <FelixBot> ---------------------------------------------
[10:32:23pm] <FelixBot> 10| Fulham| 24 | 7 | 9 | 8 | 22 | 22 | 0 | 30
[10:32:23pm] <FelixBot> ---------------------------------------------
[10:32:25pm] <FelixBot> 11| Sunderland| 25 | 8 | 6 | 11 | 27 | 33 | -6 | 30
[10:32:27pm] <FelixBot> ---------------------------------------------
[10:32:29pm] <FelixBot> 12| Hull City| 25 | 7 | 8 | 10 | 31 | 46 | -15 | 29
[10:32:31pm] <FelixBot> 13| Newcastle United| 25 | 6 | 9 | 10 | 33 | 42 | -9 | 27
[10:32:33pm] <FelixBot> 14| Bolton Wanderers| 25 | 8 | 3 | 14 | 27 | 37 | -10 | 27
[10:32:35pm] <FelixBot> 15| Portsmouth| 25 | 7 | 6 | 12 | 27 | 41 | -14 | 27
which i think makes it look more cleaner and easier to understand the only problem is i cant get --------------------------------------------- to display after every line on the table any ideas?[10:19:23pm] <FelixBot> Pos | Team | P | W | D | L | F | A | GD | PTS
[10:19:23pm] <FelixBot> ---------------------------------------------
[10:19:23pm] <FelixBot> 10|Fulham|24|7|9|8|22|22|0|30
[10:19:23pm] <FelixBot> 11|Sunderland|25|8|6|11|27|33|-6|30
[10:19:24pm] <FelixBot> 12|Hull City|25|7|8|10|31|46|-15|29
[10:19:26pm] <FelixBot> 13|Newcastle United|25|6|9|10|33|42|-9|27
[10:19:28pm] <FelixBot> 14|Bolton Wanderers|25|8|3|14|27|37|-10|27
[10:19:30pm] <FelixBot> 15|Portsmouth|25|7|6|12|27|41|-14|27
As you fill the putquick queue, your adding to it faster than it can display what your adding. So after you get to the 2nd line of hyphens, the rest aren't added because that 2nd line is already there containing the same thing and hasn't been displayed yet. All eggdrop queues have this behavior.eggdrop.conf wrote:# Allow identical messages in the server queue?
set double-server 0
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# !table channels
set table_chans {#channel1 #channel2}
#######################################################################
bind pub -|- !table show_table
package require http
proc get_table { } {
set http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
set http_token [http::config -useragent $http_uagent]
if {[catch {set http_token [::http::geturl "http://www.skysports.com/football/league/0,19540,11660,00.html" -timeout 10000]}]} {
return "error"
} {
return [http::data $http_token]
}
}
proc show_table { nick uhost hand chan arg } {
global table_chans
if {[lsearch $table_chans $chan] == -1} {
return
}
set poss [lindex [split $arg] 0]
set pos_mode 0
set arg_team_name ""
if {$poss != ""} {
if {[regexp {^[a-zA-Z ]+$} $arg]} {
set pos_mode 1
set arg_team_name $arg
}
if {[regexp {^[0-9]+$} $poss]} {
set start_pos $poss
set end_pos $poss
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :max is 20, sorry"
return
}
}
if {[regexp {^[0-9]+\-[0-9]+$} $poss]} {
set split_pos [split $poss "-"]
set start_pos [lindex $split_pos 0]
set end_pos [lindex $split_pos 1]
if {($start_pos > 20) || ($end_pos > 20)} {
putquick "PRIVMSG $nick :max is 20, sorry"
return
}
}
} {
set start_pos 1
set end_pos 20
}
if {$pos_mode == 0} {
if {$start_pos > $end_pos} {
putquick "PRIVMSG $nick :first argument must be lower than second ie. 1-20, not 20-1"
return
}
}
set all [get_table]
if {$all == "error"} {
putquick "PRIVMSG $nick :problem with connection, try again later, sorry"
return
}
regsub -all "\n" $all "" all
regsub -all "\t" $all "" all
# some number before team name
regsub -all -nocase {<tr(\s+|[a-zA-Z=\"\- ]+)>\s+<td>(\d+|\-\d+)<\/td>} $all "" all
# team points
regsub -all -nocase {<td>(\d+|\-\d+)<\/td>} $all {<pkt>\1</pkt>} all
# team name, 1st tag
regsub -all -nocase {<td><a\s+href=\"\/football\/team\/0,\d+,\d+,00\.html\">} $all "<team_title>" all
# <team> team name here </team>
regsub -all -nocase {<team_title>([a-zA-Z ]+)</a></td>} $all {<team>\1</team>} all
# new line marks
regsub -all "<team>" $all "\n<team>" all
regsub -all "<\/team>" $all "<\/team>\n" all
regsub -all "<pkt>" $all "\n<pkt>" all
regsub -all "<\/pkt>" $all "<\/pkt>\n" all
set team_pos 1
set team_idx 0
set team_list [list]
putquick "PRIVMSG $nick :Pos | Team | P | W | D | L | F | A | GD | PTS"
putquick "PRIVMSG $nick :---------------------------------------------"
# "clean" team names, points
foreach a [split $all "\n"] {
if {[string match *<team>* $a]} {
regsub -all "<team>" $a "" a
regsub -all "<\/team>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {[string match *<pkt>* $a]} {
regsub -all "<pkt>" $a "" a
regsub -all "<\/pkt>" $a "" a
lappend team_list $a
incr team_idx 1
}
if {$team_idx == 9} {
if {$pos_mode == 0} {
if {($team_pos >= $start_pos) && ($team_pos <= $end_pos)} {
putquick "PRIVMSG $nick :$team_pos|[join $team_list "|"]"
}
} {
set team_name [lindex $team_list 0]
if {[string match -nocase *$arg_team_name* $team_name]} {
putquick "PRIVMSG $nick :$team_pos|[join $team_list "|"]"
}
}
set team_list [list]
set team_idx 0
incr team_pos 1
}
}
}
putlog "football-table.tcl ver 0.2 by tomekk loaded"