<commit_before># Filename: rss.py
# Module:	rss
# Date:		25th March 2007
# Author:	<NAME>, prologic at shortcircuit dot net dot au

"""RSS

This plugin provides RSS aggregation functionality to the
user allowing the user to set personal and public RSS feeds
to be retrieved at regular intervals and messages to them.
"""

__ver__ = "0.0.1"
__author__ = "<NAME>, prologic at shortcircuit dot net dot au"

from time import time

import feedparser

from pymills.misc import strToBool
from pymills.timers import TickEvent
from pymills.event import listener, Event

from kdb.plugin import BasePlugin

class Feed(object):

	def __init__(self, url, target, interval=3600):
		self.url = url
		self.target = target
		self.interval = interval

		self.next = time() + (self.interval * 60)
		self.entries = {}
		self.title = ""
		self.link = ""
	
	def checkTime(self):
		if time() > self.next:
			self.next = time() + (self.interval * 60)
			return True
		else:
			return False
	
	def getItems(self):
		s = []

		d = feedparser.parse(self.url)

		s.append("RSS: %s (%s)" % (
			d.feed.title, d.feed.link))

		self.title = d.feed.title
		self.link = d.feed.link

		if not d.entries == self.entries:
			self.entries = d.entries
			for i, e in enumerate(d.entries[:3]):
				s.append(" %d. %s (%s)" % (
					(i + 1), e.title, e.link))
		else:
			return []

		return s
	
class RSS(BasePlugin):

	"""RSS Aggregator plugin

	Provides RSS aggregation functions allowing you to
	create public or private RSS feeds that are downlaoded
	at regular intervals and checked and display.
	See: commands rss
	"""

	def __init__(self, event, bot, env):
		BasePlugin.__init__(self, event, bot, env)

		self.entities = {}
		self.env.event.push(TickEvent(60), "rsstick")

	@listener("rsstick")
	def onRSSTICK(self, n):
		self.env.event.push(TickEvent(n), "rsstick")

		for entity in self.entities:
			for f in self.entities[entity]:<commit_msg>rss: Displays nicely now and _only_ new items<commit_after># Filename: rss.py
# Module:	rss
# Date:		25th March 2007
# Author:	<NAME>, prologic at shortcircuit dot net dot au

"""RSS

This plugin provides RSS aggregation functionality to the
user allowing the user to set personal and public RSS feeds
to be retrieved at regular intervals and messages to them.
"""

__ver__ = "0.0.2"
__author__ = "<NAME>, prologic at shortcircuit dot net dot au"

from time import mktime, time

import feedparser

from pymills.utils import notags
from pymills.misc import strToBool
from pymills.event import listener, Event

from kdb.plugin import BasePlugin

class Feed(object):

	def __init__(self, url, target, interval=3600):
		self.url = url
		self.target = target
		self.interval = interval

		self.next = time() + (self.interval * 60)
		self.entries = []
		self.title = ""
		self.link = ""
	
	def checkTime(self):
		if time() > self.next:
			self.next = time() + (self.interval * 60)
			return True
		else:
			return False
	
	def getItems(self):
		d = feedparser.parse(self.url)

		if self.title == "" and self.link == "":
			self.title = d.feed.title
			self.link = d.feed.link

		new = []
		for v in d.entries:
			e = {
					"time": mktime(v.updated_parsed),
					"title": v.title,
					"summary": notags(v.summary).strip().split("\n")[0],
					"link": v.links[0].href
					}

			if not e in self.entries:
				self.entries.append(e)
				new.append(e)

		if not new == []:
			s = []
			s.append("RSS: %s (%s)" % (
				self.title, self.link))
			for e in new[:3]:
				s.append(" * %s: %s <%s>" % (
					e["title"], e["summary"], e["link"]))
			return s
		else:
			return []
	
class RSS(BasePlugin):

	"""RSS Aggregator plugin

	Provides RSS aggregation functions allowing you to
	create public or private RSS feeds that are downlaoded
	at regular intervals and checked and display.
	See: commands rss
	"""

	def __init__(self, event, bot, env):
		BasePlugin.__init__(self, event, bot, env)

		self.entities = {}
		
		self.env.timers.add(60, "rsstick", forever=True)

	@listener("rsstick")
	def onRSSTICK(self, n):
		for entity in self.entities:
			for f in self.entities[entity]:
{'fraction_non_alphanumeric': 0.12827417380660955, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 3.450980392156863, 'pattern_counts': {'":': 5, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1955465', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1378, 'n_words': 446}