mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 20:41:21 -05:00
SpiffyTitles: urlRegularExpression channel config
This commit is contained in:
parent
877deb7a08
commit
407d85ad03
@ -60,6 +60,7 @@ from imp import reload
|
||||
|
||||
# In case we're being reloaded.
|
||||
reload(plugin)
|
||||
reload(config)
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
|
@ -66,7 +66,7 @@ conf.registerGlobalValue(
|
||||
)
|
||||
|
||||
# URL regex
|
||||
conf.registerGlobalValue(
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles,
|
||||
"urlRegularExpression",
|
||||
registry.String(
|
||||
@ -137,7 +137,7 @@ conf.registerGlobalValue(
|
||||
False,
|
||||
_(
|
||||
"""
|
||||
Keep link cache globally. This will use default values for all link templates
|
||||
Keep link cache globally. This will use global values for all link templates.
|
||||
"""
|
||||
),
|
||||
),
|
||||
|
@ -35,7 +35,7 @@ import supybot.utils as utils
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.log as log
|
||||
import re, sys, random, time, json, unicodedata, datetime
|
||||
from urllib.parse import urlparse, parse_qsl
|
||||
from urllib.parse import urlparse, parse_qsl, quote
|
||||
from bs4 import BeautifulSoup
|
||||
from jinja2 import Template
|
||||
import requests
|
||||
@ -171,7 +171,7 @@ class SpiffyTitles(callbacks.Plugin):
|
||||
% (channel)
|
||||
)
|
||||
return
|
||||
urls = self.get_urls_from_message(message)
|
||||
urls = self.get_urls_from_message(message, channel)
|
||||
if not urls:
|
||||
return
|
||||
for url in urls:
|
||||
@ -559,11 +559,11 @@ class SpiffyTitles(callbacks.Plugin):
|
||||
)
|
||||
return match
|
||||
|
||||
def get_urls_from_message(self, input):
|
||||
def get_urls_from_message(self, input, channel):
|
||||
"""
|
||||
Find the first string that looks like a URL from the message
|
||||
"""
|
||||
url_re = self.registryValue("urlRegularExpression")
|
||||
url_re = self.registryValue("urlRegularExpression", channel)
|
||||
matches = re.findall(url_re, input)
|
||||
return matches
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user