From 24a69070490a54209d69f8e4bf3bcfb48d1e2696 Mon Sep 17 00:00:00 2001 From: Andrei M Date: Mon, 2 Jul 2012 19:01:59 -0400 Subject: [PATCH] Adding multi-channel support to linx features --- modules/head.py | 6 +++--- modules/linx.py | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/modules/head.py b/modules/head.py index 38a4cbf..3f4803b 100644 --- a/modules/head.py +++ b/modules/head.py @@ -17,7 +17,7 @@ import time from html.entities import name2codepoint import web from tools import deprecated -from modules.linx import postedlink +from modules.linx import check_posted_link cj = http.cookiejar.LWPCookieJar() opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) @@ -194,9 +194,9 @@ def gettitle(uri, channel): title = title.replace('\n', '') title = title.replace('\r', '') - channels = ['#vtluug'] + channels = ['#vtluug', '#vtcsec'] if channel in channels: - title = "[ " + title + " ] " + postedlink(uri) + title = "[ " + title + " ] " + check_posted_link(uri, channel) else: title = "[ " + title + " ] " else: title = None diff --git a/modules/linx.py b/modules/linx.py index 61b78a0..689ea40 100644 --- a/modules/linx.py +++ b/modules/linx.py @@ -53,7 +53,7 @@ def lines(phenny, input): date = "today" try: - req = web.post("http://linx.li/vtluuglines", {'nickname': nickname, 'date': date, 'sender': input.nick}) + req = web.post("http://linx.li/vtluuglines", {'nickname': nickname, 'date': date, 'sender': input.nick, 'channel': input.sender}) except (HTTPError, IOError): raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.") @@ -71,7 +71,7 @@ def posted(phenny, input): return try: - req = web.post("http://linx.li/vtluugposted", {'message': message, 'sender': input.nick}) + req = web.post("http://linx.li/vtluugposted", {'message': message, 'sender': input.nick, 'channel': input.sender}) except (HTTPError, IOError): raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.") @@ -80,16 +80,15 @@ def posted(phenny, input): posted.rule = (['posted'], r'(.*)') -def postedlink(url): +def check_posted_link(url, channel): """ helper method for gettitle() """ try: - req = web.post("http://linx.li/vtluugpostedurl", {'url': url}) + req = web.post("http://linx.li/vtluugpostedurl", {'url': url, 'channel': channel}) except: - req = "" + req = "" return req -postedlink.channels = ['#vtluug'] if __name__ == '__main__': print(__doc__.strip())