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.

!tv script

Old posts that have not been replied to for several years.
Locked
M
MeJseL
Halfop
Posts: 61
Joined: Tue Nov 18, 2003 7:30 am
Location: Gothenburg , sweden

!tv script

Post by MeJseL »

Code: Select all

# tvprogram.nu.tcl v1.0 by Pixelz

# public trigger
set tvpnu(trg) "!tv"


## code below ##

package require http
setudef flag tv
set tvpnu(ver) "v1.0"

proc tvpnu_get {url} {
  global tvnu
  if {[catch {::http::geturl $url -timeout 20000} tok]} {
    return 0
  } else {
    set d [::http::data $tok]
    ::http::cleanup $tok
    regsub -all -- "\n" $d "" d
    regsub -all -nocase -- "<br>" $d "\n" d
    regsub -all -nocase -- "<a.*?>.*?</a>" $d "" d
    foreach i [split $d "\n"] {
      if {[string match *<b>* $i]} {
        append x "$i\n"
      }
    }
    regsub -all -- "<.*?>" $x "" x
    foreach i [split $x "\n"] {
      if {![string match "* - " $i]} {
        set i [string replace $i 2 2 :]
        append ret "$i\n"
      }
    }
    if {[info exists ret]} { return $ret } else { return 0 }
  }
}

proc tvpnu_urlget {chan} {
  set x "http://tvprogram.nu/cgi-tvprogram/pp1.cgi?"
  switch [string tolower $chan] {
    svt1 { set url "${x}SVT1" }
    svt2 { set url "${x}SVT2" }
    tv3 { set url "${x}TV3_SVERIGE" }
    tv4 { set url "${x}TV4" }
    kanal5 { set url "${x}KANAL5" }
    femman { set url "${x}KANAL5" }
    tv6 { set url "${x}TV6" }
    ztv { set url "${x}ZTV" }
    tv8 { set url "${x}TV8" }
    mtv { set url "${x}MTV" }
    canal+  { set url "${x}CANAL+" }
    canal+gul { set url "${x}CANAL+GUL" }
    gul { set url "${x}CANAL+GUL" }
    tv1000 { set url "${x}TV1000" }
    tv1000_cinema { set url "${x}TV1000_CINEMA" }
    cinema { set url "${x}TV1000_CINEMA" }
    bbc_prime { set url "${x}BBC_Prime" }
    bbcprime { set url "${x}BBC_Prime" }
    bbc_world { set url "${x}BBC_World" }
    bbcworld { set url "${x}BBC_World" }
    eurosport { set url "${x}Eurosport" }
    default { return 0 }
  }
  return "${url}-palmpilot.htm"
}

proc tvpnu_current {data} {
  set cnt 0
  foreach i [lsort [split $data "\n"]] {
    if {$i == ""} { continue }
    lappend lst "[incr cnt] [clock scan "[string range $i 0 4]:00"] $i"
  }
  foreach i $lst {
    if {[lindex $i 1] > [clock seconds]} {
      set place [expr [lindex $i 0] - 1]
      break
    }
  }
  if {![info exists place]} { set place $cnt }
  if {$place == [expr $cnt - 1]} { set place 1 } elseif {$place == "0"} { set place $cnt }
  set x 0
  foreach i $lst {
    incr x
    if {$x == $place} { return [lrange $i 2 end] }
  }
  return 0
}

bind pub - $tvpnu(trg) pub_tvpnu
proc pub_tvpnu {nick uhost hand chan text} {
  set text [split $text]
  global tvpnu
  set chans "SVT1, SVT2, TV3, Kanal5, TV6, ZTV, TV8, MTV, Canal+, Canal+Gul, TV1000, TV1000_Cinema, BBC_Prime, BBC_World, Eurosport"
  if {![string match *+tv* [channel info $chan]]} {
    return 0
  } elseif {$text == ""} {
    putserv "NOTICE $nick :$tvpnu(trg) <channels>"
    return 0
  } elseif {[string tolower $text] == "help"} {
    putserv "NOTICE $nick :Known channels: $chans"
    return 0
  } elseif {[llength $text] > 1} {
    foreach i $text {
      if {[tvpnu_urlget $i] == "0"} {
        putserv "NOTICE $nick :$i is not a known channel. Known channels: $chans"
        return 0
      } else {
        set data [tvpnu_get [tvpnu_urlget $i]]
        if {$data == "0"} {
          putserv "NOTICE $nick :Data fetch failed!"
          return 0
        } else {
          set data [tvpnu_current $data]
          if {$data == "0"} {
            putserv "NOTICE $nick :Parse error!"
            return 0
          } else {
            set len 0
            foreach c $text {
              set c [string length $c]
              if {$c > $len} { set len $c }
            }
            putserv "PRIVMSG $chan :[format "%-${len}s %1s" "$i" "$data"]"
          }
        }
      }
    }
    return 1
  } elseif {[tvpnu_urlget $text] == "0"} {
    putserv "NOTICE $nick :[join $text] is not a known channel. Known channels: $chans"
    return 0
  } else {
    set data [tvpnu_get [tvpnu_urlget $text]]
    if {$data == "0"} {
      putserv "NOTICE $nick :Data fetch failed!"
      return 0
    } else {
      set data [tvpnu_current $data]
      if {$data == "0"} {
        putserv "NOTICE $nick :Parse error!"
        return 0
      } else {
        putserv "PRIVMSG $chan :$data"
      }
    }
    return 1
  }
}

putlog "tv.tcl Loaded!"

This works but it a bit bad .. i have to type !tv <tvchan> .. to se whats on that chan insted of using just !tv and get like svt1, svt2, tv3, tv4, kanal5, ztv, mtv on one line anyone kind anuff to help me with that .. im new to tcl .. used to code mirc script :roll: .. and i have be asking alot of questions and i know im a bit anoing :oops:
yeah!
M
MeJseL
Halfop
Posts: 61
Joined: Tue Nov 18, 2003 7:30 am
Location: Gothenburg , sweden

Post by MeJseL »

anyone ? :roll:
yeah!
M
MeJseL
Halfop
Posts: 61
Joined: Tue Nov 18, 2003 7:30 am
Location: Gothenburg , sweden

Post by MeJseL »

:(
yeah!
t
t3ch^
Voice
Posts: 16
Joined: Sat Dec 27, 2003 7:19 pm

Post by t3ch^ »

I got this one for swedish tv.

Code: Select all

# We need http package
package req http

bind pub - !tv info:tv
proc info:tv {nick host handle chan text} {
	set url "http://tvprogram.nu/cgi-tvprogram/pp1.cgi?NU-palmpilot.htm"
	set data [http::data [http::geturl $url]]

	if {![regexp -nocase {<b>SVT1</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv1]} {set tv1 "?"}
	if {![regexp -nocase {<b>SVT2</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv2]} {set tv2 "?"}
	if {![regexp -nocase {<b>TV3 SVERIGE</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv3]} {set tv3 "?"}
	if {![regexp -nocase {<b>TV4</b>(.*?)<b>[0-9\. ]+(.*?)<b>([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv4]} {set tv4 "?"}
	if {![regexp -nocase {<b>TV4\+</b>(.*?)<b>[0-9\. ]+(.*?)<b>([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv5]} {set tv5 "?"}
	if {![regexp -nocase {<b>KANAL5</b>(.*?)<b>[0-9\. ]+(.*?)<b>([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv6]} {set tv6 "?"}
	if {![regexp -nocase {<b>ZTV</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv7]} {set tv7 "?"}

	set svt1 [lindex [split $tv1 \n] 0]
	set svt2 [lindex [split $tv2 \n] 0]
	set tv3 [lindex [split $tv3 \n] 0]
	set tv4 [lindex [split $tv4 \n] 0]
	set tv42 [lindex [split $tv5 \n] 0]
	set kanal5 [lindex [split $tv6 \n] 0]
	set ztv [lindex [split $tv7 \n] 0]

	puthelp "PRIVMSG $chan :\037SVT1:\037 \002$svt1\002 \037SVT2:\037 \002$svt2\002 \037TV3:\037 \002$tv3\002"
	puthelp "PRIVMSG $chan :\037TV4:\037 \002$tv4\002 \037TV4+:\037 \002$tv42\002 \037KANAL5:\037 \002$kanal5\002 \037ZTV:\037 \002$ztv\002"
}
Output is like this

Code: Select all

[14:11:12] [@t3ch^]: !tv
[14:11:14] [JamesBond]: SVT1: Sändningsuppehåll SVT2: ? TV3: Alla älskar Raymond 
[14:11:16] [JamesBond]: TV4: Glamour  TV4+: Sändningsuppehåll  KANAL5: Spin City  ZTV: Hitparad 
Its not to hard to edit.

hf hf
S
Steve

Post by Steve »

Hello have you are this script for German TV.

Thank you Steve.

The script on this Site tv.tcl, search by www.tvspielfilm.de is not going on my bot.

Sorry for my englisch, there is not so good.

Steve
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

tv.tcl at http://irc.macht-bloe.de/ is the most common one for german TV
S
Steve

THX

Post by Steve »

Hy GodOfSuicide

I am load the tv.tcl from this site. And my eggdropp send me on the Partyline a Error

Tcl error [pub_tv]: couldn't write file "/tmp/tv.txt": permission denied


I have a tmp an the CHMOD iss 777 .

can you help me.

Steve
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

are you sure you edited /temp and not (e.g.) ~/temp ?
S
Steve

TV script

Post by Steve »

Hello GodOfSuicide,
the tv script is running now.

in the script was a wrong Code.

Code: Select all

#Location of a temporary outputfile
set tv(output) "/tmp/tv.txt"
I have change the code:

Code: Select all

#Location of a temporary outputfile
set tv(output) "tmp/tv.txt"
and now iss the tv.tcl running.

Thank´s for help.

Steve
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Actualy, no, that's the place where you should change them to suit your needs, duh! is in the *settings* section. :o
Once the game is over, the king and the pawn go back in the same box.
g
guest
Halfop
Posts: 52
Joined: Mon Jan 19, 2004 4:15 pm

Post by guest »

if {![regexp -nocase {<b>SVT1</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv1]} {set tv1 "?"}

okay I dont understand this... can somebody explain it?
(I have read http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm and I still dont understand it...)

Thanks
t
t3ch^
Voice
Posts: 16
Joined: Sat Dec 27, 2003 7:19 pm

Post by t3ch^ »

if it cant find SVT1 info, its set to "?"
g
guest
Halfop
Posts: 52
Joined: Mon Jan 19, 2004 4:15 pm

Post by guest »

I mean the regexp -nocase {<b>SVT1</b>(.*?)<b>[0-9\. ]+([0-9a-zA-ZåäöÅÄÖ\-\.\?\:\'\n ]*)</b>} $data data2 ok tv1] part =)
User avatar
TALES
Halfop
Posts: 59
Joined: Sun Nov 09, 2003 8:45 am
Location: Netherlands
Contact:

Post by TALES »

how about this: in tcl FAQ on this forum ??
Locked