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
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

View File

@ -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())