require 'config.rb'
require 'net/http'
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
def rss(url)
if url == 'news' then
url = $newsurl
elsif url == 'planet' then
url = $planeturl
elsif url == 'slashdot' then
url = $slashdoturl
else if url == 'teensonlinux' then
url = $teensonlinux
end
content = ''
open(url) do |s| content = s.read end
feed = RSS::Parser.parse(content, false)
items = ''
i = 0
while i < 5 do
j = i+1
items = items, j, '. ', feed.items[i].title, ', '
i = j
end
return items
end
def getlink(type,x)
x = x.gsub(/\r/, "")
x = x.gsub(/\n/, "")
x = x.to_i
x = x - 1
if type == 'news' then
newscontent = ''
open($newsurl) do |s| newscontent = s.read end
news = RSS::Parser.parse(newscontent, false)
title = news.items[x].title
link = news.items[x].link
elsif type == 'planet' then
planetcontent = ''
open($planeturl) do |s| planetcontent = s.read end
planet = RSS::Parser.parse(planetcontent, false)
title = planet.items[x].title
link = planet.items[x].link
elsif type == 'slashdot' then
slashdotcontent = ''
open($slashdoturl) do |s| slashdotcontent = s.read end
slashdot = RSS::Parser.parse(slashdotcontent, false)
title = slashdot.items[x].title
link = slashdot.items[x].link
else if type == 'teensonlinux' then
teensonlinuxcontent = ''
open($teensonlinuxurl) do |s| teensonlinuxcontent = s.read end
teensonlinux = RSS::Parser.parse(teensonlinuxcontent, false)
title = teensonlinux.items[x].title
link = teensonlinux.items[x].link
end
return title, ': ', link
end