Skip to content

Commit

Permalink
adding slashdot
Browse files Browse the repository at this point in the history
  • Loading branch information
tian2992 committed Aug 19, 2013
1 parent 2f87bd8 commit eb7c338
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions plugins/diagonalpunto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
import urllib
import requests
import logging
from plugins.baseactionplugin import BaseActionPlugin
from ircmessage import IRCMessage
Expand All @@ -28,9 +28,15 @@ class diagonalpunto(BaseActionPlugin):
"""
def __init__(self):
BaseActionPlugin.__init__(self)
self.baseurl = 'http://rss.slashdot.org/Slashdot/slashdot'

def devolver_lista_de(self, url_hueco):
diagonalpunto=minidom.parse(urllib.urlopen(url_hueco))
def __fetch_data(self, url):
f = requests.get(base_url)
return f.text()

def devolver_lista_de(self, url):
string_data = self.__fetch_data(self.baseurl)
diagonalpunto=minidom.parseString(string_data)
historias=diagonalpunto.getElementsByTagName('item')
articulos=[]
for nodos in historias:
Expand All @@ -45,7 +51,7 @@ def execute(self, ircMsg, userRole, *args, **kwargs):
user = ircMsg.user
m = IRCMessage()
message = ' '.join(ircMsg.msg.split())
lista_articulos = self.devolver_lista_de('http://rss.slashdot.org/Slashdot/slashdot')
lista_articulos = self.devolver_lista_de(self.baseurl)
hp=randint(0,len(lista_articulos)-1)
m.msg=''+lista_articulos[hp][2][:228] + '...... publicado el: ' + lista_articulos[hp][3] + ' en la seccion ' + lista_articulos[hp][9]
m.channel = ircMsg.channel
Expand Down
2 changes: 1 addition & 1 deletion plugins/diagonalpunto.yapsy-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Module = diagonalpunto

[Documentation]
Author = Fernando Larrazábal
Version = 0.1
Version = 0.2
Website = ninguno
Description = mostrar noticias del rss de slashdot

0 comments on commit eb7c338

Please sign in to comment.