Adding multi-channel support to linx features

master
Andrei M 2012-07-02 19:01:59 -04:00
parent 0ba6438922
commit 24a6907049
2 changed files with 8 additions and 9 deletions

View File

@ -17,7 +17,7 @@ import time
from html.entities import name2codepoint from html.entities import name2codepoint
import web import web
from tools import deprecated from tools import deprecated
from modules.linx import postedlink from modules.linx import check_posted_link
cj = http.cookiejar.LWPCookieJar() cj = http.cookiejar.LWPCookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
@ -194,9 +194,9 @@ def gettitle(uri, channel):
title = title.replace('\n', '') title = title.replace('\n', '')
title = title.replace('\r', '') title = title.replace('\r', '')
channels = ['#vtluug'] channels = ['#vtluug', '#vtcsec']
if channel in channels: if channel in channels:
title = "[ " + title + " ] " + postedlink(uri) title = "[ " + title + " ] " + check_posted_link(uri, channel)
else: else:
title = "[ " + title + " ] " title = "[ " + title + " ] "
else: title = None else: title = None

View File

@ -53,7 +53,7 @@ def lines(phenny, input):
date = "today" date = "today"
try: 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): except (HTTPError, IOError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.") raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
@ -71,7 +71,7 @@ def posted(phenny, input):
return return
try: 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): except (HTTPError, IOError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.") raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
@ -80,16 +80,15 @@ def posted(phenny, input):
posted.rule = (['posted'], r'(.*)') posted.rule = (['posted'], r'(.*)')
def postedlink(url): def check_posted_link(url, channel):
""" helper method for gettitle() """ """ helper method for gettitle() """
try: try:
req = web.post("http://linx.li/vtluugpostedurl", {'url': url}) req = web.post("http://linx.li/vtluugpostedurl", {'url': url, 'channel': channel})
except: except:
req = "" req = ""
return req return req
postedlink.channels = ['#vtluug']
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__.strip()) print(__doc__.strip())