CNN top stories

By kllmoon on Apr 11, 2010

Screenshots

This is a script made by Scakk when I asked around on the forum. I find it usefull so i post it here.

Triggers :

!cnn help
!cnn sports, us, world, topstories, living, travel, showbizz, health, space, tech, politics, crime, money, recent
!cnn # (1 to 10) gives you a description and link to those full stories.

Changed it up to include many news feeds, not only world news feeds like before. This way, you get access to 14 news feeds

on *:text:!cnn *:#: { 
  if ($2 isnum && $2 >= 1) { set %cnnstory $round($2,0) } 
  if ($2 == sports) { set %cnnstory All | set %feed /rss/si_topstories.rss } 
  elseif ($2 == us) { set %cnnstory All | set %feed /rss/cnn_us.rss } 
  elseif ($2 == world) { set %cnnstory All | set %feed /rss/cnn_world.rss } 
  elseif ($2 == topstories) { set %cnnstory All | set %feed /rss/cnn_topstories.rss } 
  elseif ($2 == living) { set %cnnstory All | set %feed /rss/cnn_living.rss } 
  elseif ($2 == travel) { set %cnnstory All | set %feed /rss/cnn_travel.rss } 
  elseif ($2 == showbizz) { set %cnnstory All | set %feed /rss/cnn_showbiz.rss } 
  elseif ($2 == health) { set %cnnstory All | set %feed /rss/cnn_health.rss } 
  elseif ($2 == space) { set %cnnstory All | set %feed /rss/cnn_space.rss } 
  elseif ($2 == tech ) { set %cnnstory All | set %feed /rss/cnn_tech.rss } 
  elseif ($2 == politics) { set %cnnstory All | set %feed /rss/cnn_allpolitics.rss } 
  elseif ($2 == crime) { set %cnnstory All | set %feed /rss/cnn_crime.rss } 
  elseif ($2 == money) { set %cnnstory All | set %feed /rss/money_latest.rss }
  elseif ($2 == recent) { set %cnnstory All | set %feed /rss/cnn_latest.rss }
  elseif ($2 == help) { notice $nick triggers are sports, us, world, topstories, living, travel, showbizz, health, space, tech, politics, crime, money, recent
    notice $nick type !cnn sports for sports news, !cnn us for USA news, etc. Then type !cnn 1 to 10 for more info
  /halt  }
  set %cnnchan $chan 
  sockopen CNN rss.cnn.com 80 

}
on *:sockopen:CNN: { 
  sockwrite -n $sockname GET %feed HTTP/1.1 
  sockwrite -n $sockname Host: rss.cnn.com  
  sockwrite -n $sockname Connection: close 
  sockwrite -n $sockname $crlf 
} 
on *:sockread:CNN: { 
  sockread %cnntemp 
  if (<title> isin %cnntemp) { inc %tt 1 | set %cnntitle $+ %tt $nohtml(%cnntemp) } 
  if (<link> isin %cnntemp) { inc %ttt 1 | set %cnnlink $+ %ttt $nohtml(%cnntemp) } 
  if (<pubDate> isin %cnntemp) { inc %ttttt 1 | set %cnndate $+ %ttttt $nohtml(%cnntemp) } 
  if (<description> isin %cnntemp) { inc %tttt 1 | set %cnndesc $+ %tttt $remove($nohtml(%cnntemp),$(&lt;div class="feedflare"&gt;)) } 
} 
on *:sockclose:CNN: { 
  if (%cnnstory == All) { 
    var %o 3 | while (%o <= $var(%cnntitle*,0)) { 
      msg %cnnchan 4,15 [Title: $calc(%o -2) $+ ] $var(%cnntitle*,%o).value | inc %o 
    } 
  } 
  else { 
    if ($calc(%cnnstory +2) > $var(%cnntitle*,0)) { notice $nick There are only $calc($v2 -2) options. } 
    else { 
      msg %cnnchan 4,15 [Title:] $($+(%,cnntitle,$calc(%cnnstory +2)),2) 
      msg %cnnchan 4,15 [Published:] $($+(%,cnndate,$calc(%cnnstory +1)),2) 
      msg %cnnchan 4,15 [Description:] $($+(%,cnndesc,$calc(%cnnstory +2)),2) 
      msg %cnnchan 4,15 [Link:] $($+(%,cnnlink,$calc(%cnnstory +2)),2) 
    } 
  } 
  unset %cnn* %tt %ttt %tttt %ttttt 
} 
alias -l nohtml { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
}

Comments

Sign in to comment.
Kendy   -  Jun 25, 2020

error code. Someone can fixed it work correctly please. Today is 26/6/2020 ! That's code is from 2010

 Respond  
joelp53   -  May 17, 2010

little edit to make it notice the user

on *:text:!cnn *:#: { 
  if ($2 isnum && $2 >= 1) { set %cnnstory $round($2,0) } 
  if ($2 == sports) { set %cnnstory All | set %feed /rss/si_topstories.rss } 
  elseif ($2 == us) { set %cnnstory All | set %feed /rss/cnn_us.rss } 
  elseif ($2 == world) { set %cnnstory All | set %feed /rss/cnn_world.rss } 
  elseif ($2 == topstories) { set %cnnstory All | set %feed /rss/cnn_topstories.rss } 
  elseif ($2 == living) { set %cnnstory All | set %feed /rss/cnn_living.rss } 
  elseif ($2 == travel) { set %cnnstory All | set %feed /rss/cnn_travel.rss } 
  elseif ($2 == showbizz) { set %cnnstory All | set %feed /rss/cnn_showbiz.rss } 
  elseif ($2 == health) { set %cnnstory All | set %feed /rss/cnn_health.rss } 
  elseif ($2 == space) { set %cnnstory All | set %feed /rss/cnn_space.rss } 
  elseif ($2 == tech ) { set %cnnstory All | set %feed /rss/cnn_tech.rss } 
  elseif ($2 == politics) { set %cnnstory All | set %feed /rss/cnn_allpolitics.rss } 
  elseif ($2 == crime) { set %cnnstory All | set %feed /rss/cnn_crime.rss } 
  elseif ($2 == money) { set %cnnstory All | set %feed /rss/money_latest.rss }
  elseif ($2 == recent) { set %cnnstory All | set %feed /rss/cnn_latest.rss }
  elseif ($2 == help) { notice $nick triggers are sports, us, world, topstories, living, travel, showbizz, health, space, tech, politics, crime, money, recent
    notice $nick type !cnn sports for sports news, !cnn us for USA news, etc. Then type !cnn 1 to 10 for more info
  /halt  }
  set %cnnchan $chan 
  sockopen CNN rss.cnn.com 80 

}
on *:sockopen:CNN: { 
  sockwrite -n $sockname GET %feed HTTP/1.1 
  sockwrite -n $sockname Host: rss.cnn.com  
  sockwrite -n $sockname Connection: close 
  sockwrite -n $sockname $crlf 
} 
on *:sockread:CNN: { 
  sockread %cnntemp 
  if (<title> isin %cnntemp) { inc %tt 1 | set %cnntitle $+ %tt $nohtml(%cnntemp) } 
  if (<link> isin %cnntemp) { inc %ttt 1 | set %cnnlink $+ %ttt $nohtml(%cnntemp) } 
  if (<pubDate> isin %cnntemp) { inc %ttttt 1 | set %cnndate $+ %ttttt $nohtml(%cnntemp) } 
  if (<description> isin %cnntemp) { inc %tttt 1 | set %cnndesc $+ %tttt $remove($nohtml(%cnntemp),$(&lt;div class="feedflare"&gt;)) } 
} 
on *:sockclose:CNN: { 
  if (%cnnstory == All) { 
    var %o 3 | while (%o <= $var(%cnntitle*,0)) { 
      notice %cnnchan 4,15 [Title: $calc(%o -2) $+ ] $var(%cnntitle*,%o).value | inc %o 
    } 
  } 
  else { 
    if ($calc(%cnnstory +2) > $var(%cnntitle*,0)) { notice $nick There are only $calc($v2 -2) options. } 
    else { 
      notice %cnnchan 4,15 [Title:] $($+(%,cnntitle,$calc(%cnnstory +2)),2) 
      notice %cnnchan 4,15 [Published:] $($+(%,cnndate,$calc(%cnnstory +1)),2) 
      notice %cnnchan 4,15 [Description:] $($+(%,cnndesc,$calc(%cnnstory +2)),2) 
      notice %cnnchan 4,15 [Link:] $($+(%,cnnlink,$calc(%cnnstory +2)),2) 
    } 
  } 
  unset %cnn* %tt %ttt %tttt %ttttt 
} 
alias -l nohtml { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
}
 Respond  
Jethro   -  Apr 18, 2010

If you change it to echo, how are you supposed to notice the result to people, as Jenny asked? Echoing is only for the client that runs the code to see.

The easiest way to do is just add the timers in each line output.

Another way is to write the result to a text file and then play it with the -n switch.

This script can further be improved without the use of sockclose event, as I've been told that's a lazy habit in socket scripting. And it saves unnecessary line reads.

 Respond  
SglCdnMade   -  Apr 18, 2010

Oops sorry... I misread the question. My bad.

 Respond  
Jenny   -  Apr 18, 2010

Nice. How can I change this that it notice instead of msg in order not to flood the channel?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.