summaryrefslogtreecommitdiffstats
path: root/ircbot/rssbot.py
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2014-01-05 14:55:17 +0100
committerlassulus <lassulus@googlemail.com>2014-01-05 14:55:17 +0100
commit8c9e76b443adc2cd33a65dddd7ac00a39b64f26f (patch)
tree1a1c19696f18e578e7e4db7a70b6a4526a372f61 /ircbot/rssbot.py
parentfbf323d3866d524ad9b6e6028247adb746f52dde (diff)
ircbot: refactor and more features
Diffstat (limited to 'ircbot/rssbot.py')
-rwxr-xr-xircbot/rssbot.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/ircbot/rssbot.py b/ircbot/rssbot.py
index 008f9fa0..1e1d620d 100755
--- a/ircbot/rssbot.py
+++ b/ircbot/rssbot.py
@@ -27,7 +27,10 @@ class RssBot(irc.bot.SingleServerIRCBot):
self.disconnect()
def updateloop(self):
- self.feed = feedparser.parse(self.url)
+ try:
+ self.feed = feedparser.parse(self.url)
+ except:
+ print(self.name + ': rss timeout occured')
for entry in self.feed.entries:
#try:
# self.sendqueue.append(entry.title + " " + entry.link + " com: " + entry.comments)
@@ -38,7 +41,10 @@ class RssBot(irc.bot.SingleServerIRCBot):
while self.loop:
sleep(self.to)
- self.feed = feedparser.parse(self.url)
+ try:
+ self.feed = feedparser.parse(self.url)
+ except:
+ print(self.name + ': rss timeout occured')
for entry in self.feed.entries:
if not entry.link in self.oldnews:
#try:
@@ -52,17 +58,19 @@ class RssBot(irc.bot.SingleServerIRCBot):
sleep(1)
self.send(self.sendqueue.pop())
- def send(self, string):
+ def send(self, string=''):
if self.connection.connected:
- if len(string) < 450:
- self.connection.privmsg(self.chan, string)
- else:
- space = 0
- for x in range(math.ceil(len(string)/400)):
- oldspace = space
- space = string.find(" ", (x+1)*400, (x+1)*400+50)
- self.connection.privmsg(self.chan, string[oldspace:space])
- sleep(1)
+ for line in string.split('\n'):
+ if len(line) < 450:
+ self.connection.privmsg(self.chan, line)
+ else:
+ space = 0
+ for x in range(math.ceil(len(line)/400)):
+ oldspace = space
+ space = line.find(" ", (x+1)*400, (x+1)*400+50)
+ self.connection.privmsg(self.chan, line[oldspace:space])
+ sleep(1)
+ sleep(1)
else:
self.connection.reconnect()
self.send(string)