summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2014-01-06 01:54:56 +0100
committerlassulus <lassulus@googlemail.com>2014-01-06 01:54:56 +0100
commit3744f04e36147cd5ebc77ea00f70c0af2b211556 (patch)
tree3d8776fc543a43811bbdad3eecedd35dab108d8d
parentc7ab5042fef55b71baf6bb637cb6033b25007845 (diff)
ircbot: environ arguments support
-rwxr-xr-xircbot/contoller.py47
-rwxr-xr-xircbot/rssbot.py4
2 files changed, 31 insertions, 20 deletions
diff --git a/ircbot/contoller.py b/ircbot/contoller.py
index 0b31f39c..e965da88 100755
--- a/ircbot/contoller.py
+++ b/ircbot/contoller.py
@@ -2,6 +2,35 @@ from time import sleep
import irc.bot
import _thread
import rssbot
+import os
+
+feedfile = 'new_feeds'
+url_shortener = 'http://localhost'
+
+if FEEDFILE in os.environ:
+ feedfile = os.environ['FEEDFILE']
+
+if URLSHORT in os.environ:
+ url_shortener = os.environ['URLSHORT']
+
+bots = {}
+knews = NewsBot('knews')
+
+#config file reading
+F = open(feedfile, "r")
+lines = F.readlines()
+F.close()
+
+for line in lines:
+ line = line.strip('\n')
+ linear = line.split('|')
+ bot = rssbot.RssBot(linear[1], linear[0], url_shortener)
+ bot.start()
+ bots[linear[0]] = bot
+
+knews.start()
+
+
class NewsBot(irc.bot.SingleServerIRCBot):
def __init__(self, name, server='ire', port=6667, chan='#news', timeout=60):
@@ -61,24 +90,6 @@ class NewsBot(irc.bot.SingleServerIRCBot):
except:
return "mimimimi"
-feedfile = 'new_feeds'
-
-bots = {}
-knews = NewsBot('knews')
-
-#config file reading
-F = open(feedfile, "r")
-lines = F.readlines()
-F.close()
-
-for line in lines:
- line = line.strip('\n')
- linear = line.split('|')
- bot = rssbot.RssBot(linear[1], linear[0])
- bot.start()
- bots[linear[0]] = bot
-
-knews.start()
class commands():
diff --git a/ircbot/rssbot.py b/ircbot/rssbot.py
index f0e19c5a..cb7a1543 100755
--- a/ircbot/rssbot.py
+++ b/ircbot/rssbot.py
@@ -9,7 +9,7 @@ from datetime import datetime
from time import sleep
class RssBot(irc.bot.SingleServerIRCBot):
- def __init__(self, rss, name, server='ire', port=6667, chan='#news', timeout=60):
+ def __init__(self, rss, name, url_shortener="http://localhost", server='ire', port=6667, chan='#news', timeout=60):
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], name, name)
self.url = rss
self.name = name
@@ -47,7 +47,7 @@ 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, "http://wall:1337"]).decode()
+ shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + entry.link, url_shortener]).decode()
self.send(entry.title + " " + shorturl)
self.oldnews.append(entry.link)
self.lastnew = datetime.now()