egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

News Now Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Wed Jul 04, 2012 4:50 am    Post subject: News Now Script Reply with quote

I was hoping this website has an rss feed I can use for that page, but it doesn't.

So is there any chance someone would be willing to write a script to send announcements with the headline & link every time a new headline is announced on the website please? (A news script)
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Wed Jul 04, 2012 12:04 pm    Post subject: Reply with quote

use there twitter rss feed?

https://twitter.com/statuses/user_timeline/68672354.rss
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Wed Jul 04, 2012 12:05 pm    Post subject: Reply with quote

It provides news from all their sections, I want news just from that specific one
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Wed Jul 04, 2012 12:06 pm    Post subject: Reply with quote

i just realized that after posting :/

sorry
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Fri Jul 20, 2012 12:16 pm    Post subject: Reply with quote

Anyone?
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sat Jul 21, 2012 5:27 pm    Post subject: Reply with quote

i gave it a go for you, left it running for a while and it seems to work fine lots of news was posted anyways Very Happy see here http://pastebin.com/raw.php?i=YdZjUFgu

what it does is check this part of the page http://i.imgur.com/DETiC.png for ne articles stores the info in a .txt file so only announces the article once in channel. also worked in a cache to remove articles announced over ten mins ago so the txt file wont become massive!

here it is

Code:
# newsnow.tcl
# by doggo #omgwtfnzbs@EFNET
#########################

package require http
bind time -|- "*" newsnowuk:news

set infochan "#yourchannel"
set baseurl "http://www.newsnow.co.uk"
set dupes "logs/newsnow_dupes.txt"

proc newsnowuk:news {min hour day month year} {
global infochan baseurl dupes

   if {![file exists $dupes]} {
      set file [open $dupes "w"]
      close $file
   }

   set url "http://www.newsnow.co.uk/h/Sport/Football"

   ::http::config -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
   set data [::http::geturl $url -timeout 5000]
   set xx [::http::data $data]
   ::http::cleanup $xx

   regsub -all {\n} $xx {} xx
   regexp -nocase {<div class="tsl">NEW in the last (.*?)</div>(.*?)<br.*} $xx match x1 x2 x3

   if {![info exists x2]} {return}

   regsub -all {</div>} $x2 {|} x2

   foreach xxx [split $x2 "|"] {
   if {[string length $xxx]} {

   regexp -nocase {<a href="(.*?)".*onclick=".*">(.*?)</a><span class=".*" ut=".*"><b>(.*?)</b>} $xxx match x4 x5 x6

   set file [open $dupes r]
   set data [read $file]
   close $file
   set isdupe 0
   foreach yy [split $data \n] {
   if {[string length $yy]} {

   set now [clock seconds]
   set cache [lindex $yy 0]
   set article [lindex $yy 1]
   incr now -$cache

        if { [string match -nocase "*$x4*" "$yy"] == 1 } {
            set isdupe 1
        }

   if {$now>600} {
   set rmv [newsnowuk:cache $cache $dupes]
   putlog "removing news article $article from cache"
     }
    }
   }
   catch {unset data}
   
   if {$isdupe != 1} {
   set x5 [newsnowuk:htmlcodes $x5]

   regsub -all {\s+} $x5 " " x5
   regsub -all {\–} $x5 "-" x5
   regsub -all {\’|\‘} $x5 "\'" x5

   set open_text [open $dupes "a"]
   puts $open_text "[clock seconds] $x4"
   close $open_text

   puthelp "privmsg $infochan :$x5 - $baseurl$x4"

   }
  }
 }
}

proc newsnowuk:cache {id fname} {

   set data ""
   set input [open $fname r]
   while {![eof $input]} {
   set curline [gets $input];set curline [split $curline]
   if {$curline != ""} {
   set data [linsert $data end $curline]
    }
   }
   catch {close $input}
   set mark -1;set match ""
   foreach line $data {
   incr mark
   if {[lindex $line 0] == $id} {
   set match $mark
   break
    }
   }
   if {$match == ""} {return}
   set newdata [lreplace $data $mark $mark]
   set output [open $fname w]
   foreach newline $newdata {
   if {$newline != ""} {
   puts $output $newline
    }
   }
   flush $output
   catch {close $output}

}

#borrowed from a imdb.tcl
proc newsnowuk:htmlcodes {content} {
   if {$content == ""} {
   return "n/a";
   }
   if {![string match *&* $content]} {
   return $content;
   }
   set escapes {
   &nbsp; \x20 &quot; \x22 &amp; \x26 &apos; \x27 &ndash; \x2D
   &lt; \x3C &gt; \x3E &tilde; \x7E &euro; \x80 &iexcl; \xA1
   &cent; \xA2 &pound; \xA3 &curren; \xA4 &yen; \xA5 &brvbar; \xA6
   &sect; \xA7 &uml; \xA8 &copy; \xA9 &ordf; \xAA &laquo; \xAB
   &not; \xAC &shy; \xAD &reg; \xAE &hibar; \xAF &deg; \xB0
   &plusmn; \xB1 &sup2; \xB2 &sup3; \xB3 &acute; \xB4 &micro; \xB5
   &para; \xB6 &middot; \xB7 &cedil; \xB8 &sup1; \xB9 &ordm; \xBA
   &raquo; \xBB &frac14; \xBC &frac12; \xBD &frac34; \xBE &iquest; \xBF
   &Agrave; \xC0 &Aacute; \xC1 &Acirc; \xC2 &Atilde; \xC3 &Auml; \xC4
   &Aring; \xC5 &AElig; \xC6 &Ccedil; \xC7 &Egrave; \xC8 &Eacute; \xC9
   &Ecirc; \xCA &Euml; \xCB &Igrave; \xCC &Iacute; \xCD &Icirc; \xCE
   &Iuml; \xCF &ETH; \xD0 &Ntilde; \xD1 &Ograve; \xD2 &Oacute; \xD3
   &Ocirc; \xD4 &Otilde; \xD5 &Ouml; \xD6 &times; \xD7 &Oslash; \xD8
   &Ugrave; \xD9 &Uacute; \xDA &Ucirc; \xDB &Uuml; \xDC &Yacute; \xDD
   &THORN; \xDE &szlig; \xDF &agrave; \xE0 &aacute; \xE1 &acirc; \xE2
   &atilde; \xE3 &auml; \xE4 &aring; \xE5 &aelig; \xE6 &ccedil; \xE7
   &egrave; \xE8 &eacute; \xE9 &ecirc; \xEA &euml; \xEB &igrave; \xEC
   &iacute; \xED &icirc; \xEE &iuml; \xEF &eth; \xF0 &ntilde; \xF1
   &ograve; \xF2 &oacute; \xF3 &ocirc; \xF4 &otilde; \xF5 &ouml; \xF6
   &divide; \xF7 &oslash; \xF8 &ugrave; \xF9 &uacute; \xFA &ucirc; \xFB
   &uuml; \xFC &yacute; \xFD &thorn; \xFE &yuml; \xFF
   };
   set content [string map $escapes $content];
   set content [string map [list "\]" "\\\]" "\[" "\\\[" "\$" "\\\$" "\\" "\\\\"] $content];
   regsub -all -- {&#([[:digit:]]{1,5});} $content {[format %c [string trimleft "\1" "0"]]} content;
   regsub -all -- {&#x([[:xdigit:]]{1,4});} $content {[format %c [scan "\1" %x]]} content;
   regsub -all -- {&#?[[:alnum:]]{2,7};} $content "?" content;
   return [subst $content];

}

putlog "newsnow.tcl loaded!"


enjoy Very Happy
_________________
NON geeky!! http://gotcode4u.com/


Last edited by doggo on Sun Jul 22, 2012 6:44 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Sun Jul 22, 2012 1:52 am    Post subject: Reply with quote

Thats some good [censored] right there mate, exactly what I wanted and it works splendid! thanks so much!
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sun Jul 22, 2012 8:58 am    Post subject: Reply with quote

cool Very Happy
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Wed Jan 09, 2013 2:59 pm    Post subject: Reply with quote

hey doggo,

Any chance for a few adjustments for the script? while running the script on the eggdrop it seems to take a lot of CPU and when I mean a lot I mean atleast 40%, sometimes even more.

could you add an update interval and how many results to return each time an update occurs (like every X minutes it will retrieve the latest Y search items?)
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Sat Feb 09, 2013 7:45 am    Post subject: Reply with quote

Maybe someone else could help?
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber