Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding:Utf-8 -*-
- from __future__ import with_statement
- import es
- import os
- import re
- regex = re.compile(r"""\b(?:http|telnet|gopher|file|wais|ftp):[\w/#~:.?+=&%@!\-.:?\-]+?(?=[.:?\-]*(?:[^\w/#~:.?+=&%@!\-.:?\-]|$))""", re.VERBOSE | re.MULTILINE | re.IGNORECASE)
- es.ServerVar('ucf_version', 1.0, 'Version of the URLChatFilter\'s script by FMIS | Menace.').makepublic()
- def getURLWhiteList(path):
- with open(path, 'r') as file:
- return [n for n in file.read().splitlines() if not n.startswith('#')]
- def removeURLFromString(string):
- for url in regex.findall(string):
- if url not in URLWhiteList:
- if ucf_method == 'hidden':
- string = string.replace(url, re.sub('[^\.:/]', '*', url))
- elif ucf_method == 'deleted':
- string = string.replace(url, '')
- elif ucf_method == 'changed':
- string = string.replace(url, ucf_urltoreplace)
- return string
- def sayFilter(userid, text, teamonly):
- return(userid, removeURLFromString(text.strip('"')), teamonly)
- def es_map_start(ev):
- global IPWhiteList
- IPWhiteList = getIpWhiteList(os.path.join(es.getAddonPath('urlchatfilter'), 'urlwhitelist.txt'))
- def load(): es.addons.registerSayFilter(sayFilter)
- def unload(): es.addons.unregisterSayFilter(sayFilter)
- URLWhiteList = getURLWhiteList(os.path.join(es.getAddonPath('urlchatfilter'), 'urlwhitelist.txt'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement