fix: optimized urlban logic

This commit is contained in:
Terry Geng 2020-03-12 19:59:23 +08:00
parent a2cb955ed8
commit c1190d6317
2 changed files with 9 additions and 6 deletions

View File

@ -235,9 +235,11 @@ class MumbleBot:
constants.strings('user_ban')) constants.strings('user_ban'))
return return
if parameter: if not self.is_admin(user) and parameter:
input_url = util.get_url_from_input(parameter.lower())
if input_url:
for i in var.db.items("url_ban"): for i in var.db.items("url_ban"):
if util.get_url_from_input(parameter.lower()) == i[0]: if input_url == i[0]:
self.mumble.users[text.actor].send_text_message( self.mumble.users[text.actor].send_text_message(
constants.strings('url_ban')) constants.strings('url_ban'))
return return

View File

@ -294,6 +294,7 @@ class Dir(object):
# Parse the html from the message to get the URL # Parse the html from the message to get the URL
def get_url_from_input(string): def get_url_from_input(string):
string = string.strip()
if string.startswith('http'): if string.startswith('http'):
return string return string
p = re.compile('href="(.+?)"', re.IGNORECASE) p = re.compile('href="(.+?)"', re.IGNORECASE)