Adding multi-channel support to linx features
parent
0ba6438922
commit
24a6907049
|
@ -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
|
||||||
|
|
|
@ -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())
|
||||||
|
|
Loading…
Reference in New Issue