forked from colons/pyfoot-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.py
More file actions
43 lines (34 loc) · 1.41 KB
/
rss.py
File metadata and controls
43 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from time import sleep
import feedparser
import plugin
defaults = {
'rss_feeds': {},
}
class Plugin(plugin.Plugin):
"""<pyfoot> is capable of reading an RSS feed into a channel, but it's not configurable live. Talk to whoever is operating your local pyfoot instance if you have a feed you'd like in a channel."""
def prepare(self):
self.latestitem = {}
for channel in self.conf.conf['rss_feeds']:
# get latest item, remember to ignore it
url = self.conf.conf['rss_feeds'][channel]
try:
feed = feedparser.parse(url)
self.latestitem[url] = feed['items'][0]
except:
pass
def run(self):
while True:
sleep(150)
for channel in self.conf.conf['rss_feeds']:
url = self.conf.conf['rss_feeds'][channel]
try:
feed = feedparser.parse(url)
item = feed['items'][0]
except:
pass
else:
if item['link'] != self.latestitem[url]['link']:
self.latestitem[url] = feed['items'][0]
title = self.latestitem[url]['title']
link = self.latestitem[url]['link']
self.irc.privmsg(channel, '%s | %s' % (title, link), pretty=True)