summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xircbot/contoller.py1
-rwxr-xr-xircbot/rssbot.py17
2 files changed, 15 insertions, 3 deletions
diff --git a/ircbot/contoller.py b/ircbot/contoller.py
index 1d9347c3..bf4dd578 100755
--- a/ircbot/contoller.py
+++ b/ircbot/contoller.py
@@ -116,7 +116,6 @@ class commands():
return 'bot not found'
-
feedfile = 'new_feeds'
url_shortener = 'http://wall'
init_channels = ['#news']
diff --git a/ircbot/rssbot.py b/ircbot/rssbot.py
index 225e6f13..45af1dc3 100755
--- a/ircbot/rssbot.py
+++ b/ircbot/rssbot.py
@@ -57,12 +57,25 @@ class RssBot(irc.bot.SingleServerIRCBot):
#try:
# self.send(entry.title + " " + entry.link + " com: " + entry.comments)
#except AttributeError:
- shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + entry.link, self.url_shortener]).decode()
- self.send(entry.title + " " + shorturl.strip('\n').strip('\r') + '#' + entry.link.partition('://')[2].partition('/')[0])
+ shorturl = self.shortenurl(entry.link)
+ self.send(entry.title + ' ' + shorturl)
self.oldnews.append(entry.link)
self.lastnew = datetime.now()
sleep(self.to)
+ def shortenurl(self, url):
+ while True:
+ try:
+ shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + url, self.url_shortener]).decode().strip('\n').strip('\r') + '#' + url.partition('://')[2].partition('/')[0]
+ return shorturl
+ except:
+ print('url shortener error')
+ sleep(1)
+
+ def last(self, num):
+ for feed in reversed([x for x in reversed(self.feed.entries)][:num]):
+ self.send(feed.title + ' ' + self.shortenurl(feed.link))
+
def send(self, string):
if self.connection.connected:
for line in string.split('\n'):