<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/5511" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2003-09-09T14:51:23-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/5511</id>

		<entry>
		<author><name><![CDATA[Yourname]]></name></author>
		<updated>2003-09-09T14:51:23-04:00</updated>

		<published>2003-09-09T14:51:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=26827#p26827</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=26827#p26827"/>
		<title type="html"><![CDATA[abcnews]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=26827#p26827"><![CDATA[
<img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_evil.gif" width="15" height="15" alt=":evil:" title="Evil or Very Mad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=13">Yourname</a> — Tue Sep 09, 2003 2:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-09-06T11:36:42-04:00</updated>

		<published>2003-09-06T11:36:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=26625#p26625</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=26625#p26625"/>
		<title type="html"><![CDATA[abcnews]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=26625#p26625"><![CDATA[
I love this script but for some reason it stops parsing news after a few hours. No errors, nothing, it just stops, as if the script was unloaded. The only way to make it work again is by .restart. A friend said it may be because of a utimer problem?<br><br>I don't know anything about TCL scripting, so if anybody could please hint on what may be wrong, I'd appreciate it a lot. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>abcnews.tcl:<div class="codebox"><p>Code: </p><pre><code>################################################################ ABCNews Script v1.1 by ThEdGE### ### This will echo all the new headlines from abcnews.com in your channel,### also the ability to get the last 5 headlines with a trigger.###### V1.1:###  Cleaned up some code, and made some cosmetic changes.###  Fixed problem with regsub not being compatible.###  Changed the HTTP Request header.################################################################ Options, read the discriptions carefully, ### leave default if you dont know sure what to put!### Set the channel(s) where the script will function.set abcchans { "#mychatchannel"}### Set the trigger for the last 5 headlines.## Default: !showlastset lasttrigger "!showlast"### Set the help msg trigger for the last 5 headlines.## Default: !abchelpset helptrigger "!abchelp"### Set the update interval for the news announcing,### please note that one update is about 25kb,### so a interval of 3mins is about 12MB a day.### A interval around 10mins will skip news postings!## Default: 3set interval "3"### Set a file for the script to use for data storage.## Default: scripts/abcnews.dataset datafile "scripts/abcnews.data"### Here you can select what part of the world you want the script to announce headlines for.###Available options are: ###af : Africa###as : Asia###er : Europe###la : Latin America###me : Middle East###na : North America###wo : The World## Default: woset part "wo"### Dont touch the code below, or it will fux0r :)##########################################################################################################################bind PUB - $lasttrigger abclastbind PUB - $helptrigger abchelp### Update procedure.proc abcupdate {} {global part datafile ### Reset some variables. set oldhash "" set newhash "" set raw "" set hl "" set url "" set title "" set time "" set partline "" ### Check what part of the world is configured. if {$part != "wo"} {  set partline "$part/index.html" } else {  set partline "index.html" } ### Send HTTP header to ABC and read from the socket. if {[catch { set socket [socket "abcnews.go.com" 80] } error]} {  putlog "ABCNews ERROR: cant open socket!"  return } fconfigure $socket -buffering line -blocking 0 puts -nonewline $socket "GET /wire/World/$partline HTTP/1.1\n" puts -nonewline $socket "Connection: Keep-Alive\n" puts -nonewline $socket "Host: http://abcnews.go.com\n\n" puts -nonewline $socket "Pragma: no-cache\n\n" while {![eof $socket]} {  set line [gets $socket]  ### Check if line aint empty.  if {$line != ""} {   ### Check for the pattern of the first headline and format it.   if {[regexp {(black9pt).*(&lt;/div&gt;&lt;/TD&gt;)} $line rline]} {    # url    regexp {(&lt;a href=\").*(\" )} $rline url    regsub "&lt;a href=\"" $url " " url    regsub "\" " $url " " url    set url [string trim $url]    # title    regexp {(class=\"blueSmall\"&gt;).*(&lt;/a&gt;)} $rline title    regsub "class=\"blueSmall\"&gt;" $title " " title    regsub "&lt;/a&gt;" $title " " title    set title [string trim $title]    #time    regexp {(  ).*(&lt;/div&gt;)} $rline time    regsub "  " $time " " time    regsub "&lt;/div&gt;" $time " " time    set time [string trim $time]    ### Get the old hash from the datafile    set f [open $datafile r]    fconfigure $f -blocking 0    set oldhash [gets $f]    close $f    set newhash [md5 $title$url$time]    ### Compair the both hashes, announce news if they differ and create new datafile.    if {$newhash != $oldhash} {     abcmsg "\[\002ABCNews\002\] $title \037(\037\037http://abcnews.go.com$url\037\037)\037"    }     set f [open $datafile w]     fconfigure $f -blocking 0     puts $f "$newhash"     close $f     ### Close/flush the socket and start the new timer.     starttimer     flush $socket     close $socket     return     # end if    }    # end if   }   # end while  }    ### Close/flush the socket and start the new timer, altho this should not be needed.    starttimer    flush $socket    close $socket # end proc}### Show last headlines procedure.proc abclast {nick uhost handle chan arg} {global abcchans ### Check for the proper channel. set properchan "0" set chan [string tolower $chan] foreach channel $abcchans { set channel [string tolower $channel]  if {$chan==$channel} {   set properchan "1"    } } if {$properchan=="0"} {  return } ### Reset some variables. set partname "" set partline ""  ### Check for arguments and format. if {$arg == "" || $arg!="af" &amp;&amp; $arg!="as" &amp;&amp; $arg!="er" &amp;&amp; $arg!="la" &amp;&amp; $arg!="me" &amp;&amp; $arg!="na"} {  set partline "index.html" } else {  set partline "$arg/index.html" }  ### Format the part of the world to request. if {$arg=="af"} { set partname "Africa" } if {$arg=="as"} { set partname "Asia" } if {$arg=="er"} { set partname "Europe" } if {$arg=="la"} { set partname "Latin America" } if {$arg=="me"} { set partname "Middle East" } if {$arg=="na"} { set partname "North America" } if {$arg== "" } { set partname "The World" } if {$partname==""} { set partname "The World" } ### Send HTTP header to ABC and read from the socket. if {[catch { set socket [socket "abcnews.go.com" 80] } error]} {  putlog "ABCNews ERROR: cant open socket!"  return } fconfigure $socket -buffering line -blocking 0 puts -nonewline $socket "GET /wire/World/$partline HTTP/1.1\n" puts -nonewline $socket "Connection: Keep-Alive\n" puts -nonewline $socket "Host: http://abcnews.go.com\n" puts -nonewline $socket "Pragma: no-cache\n\n" set nr 0 puthelp "NOTICE $nick : Last \0025\002 headlines from \002ABCNews\002 for \002$partname\002 -&gt;" while {![eof $socket]} {  set line [gets $socket]  ### Check if line aint empty.  if {$line != ""} {   ### Check each line for the pattern of the first headline and format it.   if {[regexp {(black9pt).*(&lt;/div&gt;&lt;/TD&gt;)} $line rline]} {    # url    regexp {(&lt;a href=\").*(\" )} $rline url    regsub "&lt;a href=\"" $url " " url    regsub "\" " $url " " url    set url [string trim $url]    # title    regexp {(class=\"blueSmall\"&gt;).*(&lt;/a&gt;)} $rline title    regsub "class=\"blueSmall\"&gt;" $title " " title    regsub "&lt;/a&gt;" $title " " title    set title [string trim $title]    #time    regexp {(  ).*(&lt;/div&gt;)} $rline time    regsub "  " $time " " time    regsub "&lt;/div&gt;" $time " " time    set time [string trim $time]    ### Check the length of the time, if its 7 chars fill it up with a 0.    set len [string length $time]    if {$len == "7"} {     set time "0$time"    }    incr nr    puthelp "NOTICE $nick : \002\[\002$nr \002@\002 $time\002\]\002 $title \037(\037\037http://abcnews.go.com$url\037\037)\037"    ### If the end is reached Close/flush the socket.    if {$nr == "5"} {     flush $socket     close $socket     return     # close if    }    # close if   }   # close if  }  # close while } ### Close/flush the socket, altho this should not be needed! flush $socket close $socket return # close proc }### Procedure which will show the user a bit of info.proc abchelp {nick uhost handle chan arg} {global abcchans lasttrigger ### Check for the proper channel. set properchan "0" set chan [string tolower $chan] foreach channel $abcchans { set channel [string tolower $channel]  if {$chan==$channel} {   set properchan "1"    } } if {$properchan=="0"} {  return } puthelp "PRIVMSG $nick : \002ABCNews\002 v\0021.0\002 by \002ThEdGE\002 (Help) -&gt;" puthelp "PRIVMSG $nick : Use \002$lasttrigger\002 &lt;letters&gt; to get the bot notice you the headlines." puthelp "PRIVMSG $nick : Available parts of the world:" puthelp "PRIVMSG $nick : \002af\002 : Africa" puthelp "PRIVMSG $nick : \002as\002 : Asia" puthelp "PRIVMSG $nick : \002er\002 : Europe" puthelp "PRIVMSG $nick : \002la\002 : Latin America" puthelp "PRIVMSG $nick : \002me\002 : Middle East" puthelp "PRIVMSG $nick : \002na\002 : North America" puthelp "PRIVMSG $nick : \002wo\002 : The World" puthelp "PRIVMSG $nick : For example \"\002$lasttrigger er\002\" to get the headlines for Europe."}### Procedure which handles the timers.proc starttimer {} {global interval ### check if timer is already started, maybe rehashing? set timerstarted "0" foreach timer [timers] {  if {[regexp {(abcupdate).*(timer)} $timer temp]} {   set timerstarted "1"  }  } ### Start new timer if not already started. if {$timerstarted == "0"} {  timer $interval abcupdate }}### Procedure which will echo the final text to the channel.proc abcmsg {text} {global abcchans foreach chan $abcchans {  putserv "PRIVMSG $chan : $text" }}### Start the timer when the script is loaded.starttimer    ### Check if datafile exists, create if not found.    if {[catch { open $datafile r } error]} {      set fnew [open $datafile w]     fconfigure $fnew -blocking 0     close $fnew    }putlog "Loaded: ABCNews script by ThEdGE"</code></pre></div><p>Statistics: Posted by Guest — Sat Sep 06, 2003 11:36 am</p><hr />
]]></content>
	</entry>
	</feed>
