summaryrefslogtreecommitdiffstats
path: root/news/newsbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'news/newsbot.py')
-rw-r--r--news/newsbot.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/news/newsbot.py b/news/newsbot.py
index 8834851d..2f8bf635 100644
--- a/news/newsbot.py
+++ b/news/newsbot.py
@@ -17,7 +17,7 @@ from time import sleep
## Newsbot Controller Class
class NewsBot(asybot):
- def __init__(self, name, channels=['#test'], server='ire', port=6667, timeout=60, loglevel=logging.ERROR, url_shortener='http://wall'):
+ def __init__(self, name, channels=['#test'], server='ire', port=6667, timeout=60, loglevel=logging.ERROR, url_shortener='http://localhost'):
asybot.__init__(self, server, port, name, channels, loglevel=loglevel)
self.to = timeout
self.url_shortener = url_shortener
@@ -140,7 +140,9 @@ class RssBot(asybot):
self.lastnew = datetime.now()
self.url_shortener = url_shortener
self.retry = True
- self.on_nickinuse = lambda: None
+
+ def on_nickinuse(*bla):
+ pass
def start_rss(self):
self.upd_loop = threading.Thread(target=self.updateloop)
@@ -203,19 +205,19 @@ class RssBot(asybot):
def send_msg(self, target, string):
if self.connected:
for line in string.split('\n'):
- if len(line) < 450:
- self.PRIVMSG(target, 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.PRIVMSG(target, line[oldspace:space])
+ while len(line)>0:
+ if len(line) < 450:
+ self.PRIVMSG(target, line)
+ line = ''
+ else:
+ space = line.rfind(" ", 1, 450)
+ self.PRIVMSG(target, line[:space])
+ line=line[space:]
else:
self.reconnect()
while not self.connected:
- sleep(10)
print(self.nickname + ' waiting for reconnect')
+ sleep(10)
self.send_msg(target, string)
def on_invite(self, prefix, command, params, rest):
@@ -223,12 +225,16 @@ class RssBot(asybot):
self.push('JOIN ' + chan)
self.channels.append(chan)
+ def on_welcome(self, prefix, command, params, rest):
+ asybot.on_welcome(self, prefix, command, params, rest)
+ self.push('MODE ' + self.nickname + ' +D')
+
feedfile = 'new_feeds'
-url_shortener = 'http://wall'
+url_shortener = 'http://go'
init_channels = ['#news']
bots = {}
-knews = NewsBot('knews', init_channels)
+knews = NewsBot('knews', init_channels, url_shortener=url_shortener)
#config file reading
F = open(feedfile, "r")