From 1ca2ea9a3a24ee6d19f61739e3b8363c108710d5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 6 Jan 2014 01:09:46 +0100 Subject: ircbot: subs url without regex --- ircbot/rssbot.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ircbot/rssbot.py b/ircbot/rssbot.py index 67f407ac..f0e19c5a 100755 --- a/ircbot/rssbot.py +++ b/ircbot/rssbot.py @@ -47,17 +47,14 @@ class RssBot(irc.bot.SingleServerIRCBot): #try: # self.send(entry.title + " " + entry.link + " com: " + entry.comments) #except AttributeError: - self.send(entry.title + " " + entry.link) + shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + entry.link, "http://wall:1337"]).decode() + self.send(entry.title + " " + shorturl) self.oldnews.append(entry.link) self.lastnew = datetime.now() sleep(self.to) def send(self, string): - urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', string) - for url in urls: - shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + url, "http://wall:1337"]).decode() - string = string.replace(url, shorturl) if self.connection.connected: for line in string.split('\n'): if len(line) < 450: -- cgit v1.2.3