Exemplo n.º 1
0
Arquivo: url.py Projeto: adiq/stah
def get_title_auto(code, input):
    if input.startswith(code.prefix) or input.startswith('?'):
        return  # Prevent triggering of other plugins
    urls = re.findall('(?i)' + url_re, input)
    # If a user wants to spam... lets limit is to 3 URLs max, per line
    if len(urls) > 3:
        urls = urls[0:3]
    output = []
    for url in urls:
        # check to see if we should ignore this URL...
        if '.' not in url:
            break
        if url.startswith('.') or url.endswith('.'):
            break
        for bad in ignored:
            if bad.lower() in url.lower():
                skip = True
                break
            else:
                skip = False
        if skip:
            break
        # Lets get some data!
        data = get_url_data(url)
        if data:
            output.append('{blue}{b}%s{b}{c} - %s' %
                          (web.uncharset(data), url))
    if not output:
        return
    return code.say(' | '.join(output))
Exemplo n.º 2
0
Arquivo: irc.py Projeto: CHCMATT/Code
 def format(self, message, legacy=None, charset=None):
     '''
         formatting to support color/bold/italic/etc assignment
         in Codes responses
     '''
     message = uncharset(message)
     if not hasattr(self.config, 'textstyles'):
         return self.clear_format(message)
     if not self.config.textstyles:
         return self.clear_format(message)
     if legacy:
         message = '{%s}%s{%s}' % (legacy, message, legacy)
     find_char = re.compile(r'{.*?}')
     charlist = find_char.findall(message)
     try:
         for formatted_char in charlist:
             char = formatted_char[1:-1]
             if char.startswith('/'):
                 char = char[1::]  # Assume closing {/char}
             if char in self.special_chars:
                 message = message.replace(
                     formatted_char, self.special_chars[char], 1
                 )
         return message
     except:
         return self.clear_format(message)
Exemplo n.º 3
0
Arquivo: url.py Projeto: wolfy852/Code
def get_title_auto(code, input):
    if input.startswith(code.prefix) or input.startswith('?'):
        return  # Prevent triggering of other plugins
    urls = re.findall('(?i)' + url_re, input)
    # If a user wants to spam... lets limit is to 3 URLs max, per line
    if len(urls) > 3:
        urls = urls[0:3]
    output = []
    for url in urls:
        # check to see if we should ignore this URL...
        if '.' not in url:
            break
        if url.startswith('.') or url.endswith('.'):
            break
        for bad in ignored:
            if bad.lower() in url.lower():
                skip = True
                break
            else:
                skip = False
        if skip:
            break
        # Lets get some data!
        data = get_url_data(url)
        if data:
            url = clean_url(url)
            output.append('{blue}{b}%s{b}{c} - %s' %
                          (web.uncharset(data), url))
    if not output:
        return
    return code.say(' | '.join(output))
Exemplo n.º 4
0
Arquivo: irc.py Projeto: wolfy852/Code
 def format(self, message):
     '''
         formatting to support color/bold/italic/etc assignment
         in Codes responses
     '''
     message = uncharset(message)
     if not self.config('text_decorations'):
         return self.clear_format(message)
     try:
         message = message.format(**self.special_chars)
         return message
     except:
         return self.clear_format(message)
Exemplo n.º 5
0
Arquivo: irc.py Projeto: CHCMATT/Code
 def stripcolors(self, data):
     """STRIP ALL ZE COLORS! Note: the replacement method is CRUCIAL to keep from
        left over color digits. Order is very important."""
     colors = [
         u"\x0300", u"\x0301", u"\x0302", u"\x0303", u"\x0304", u"\x0305",
         u"\x0306", u"\x0307", u"\x0308", u"\x0309", u"\x0310", u"\x0311",
         u"\x0312", u"\x0313", u"\x0314", u"\x0315", u"\x031", u"\x032",
         u"\x033", u"\x034", u"\x035", u"\x036", u"\x037", u"\x038", u"\x039",
         u"\x030", u"\x03", u"\x02", u"\x09", u"\x13", u"\x0f", u"\x15"
     ]
     data = uncharset(data)
     for color in colors:
         data = data.replace(color, '')
     return str(data.encode('ascii', 'ignore'))
Exemplo n.º 6
0
Arquivo: irc.py Projeto: wolfy852/Code
 def stripcolors(self, data):
     """STRIP ALL ZE COLORS! Note: the replacement method is CRUCIAL to keep from
        left over color digits. Order is very important."""
     colors = [
         u"\x0300", u"\x0301", u"\x0302", u"\x0303", u"\x0304", u"\x0305",
         u"\x0306", u"\x0307", u"\x0308", u"\x0309", u"\x0310", u"\x0311",
         u"\x0312", u"\x0313", u"\x0314", u"\x0315", u"\x031", u"\x032",
         u"\x033", u"\x034", u"\x035", u"\x036", u"\x037", u"\x038",
         u"\x039", u"\x030", u"\x03", u"\x02", u"\x09", u"\x13", u"\x0f",
         u"\x15"
     ]
     data = uncharset(data)
     for color in colors:
         data = data.replace(color, '')
     return str(data.encode('ascii', 'ignore'))
Exemplo n.º 7
0
Arquivo: irc.py Projeto: Csstform/Code
 def format(self, message, shorten_urls=True):
     '''
         formatting to support color/bold/italic/etc assignment
         and URL shortening in Codes responses
     '''
     message = uncharset(message)
     if self.config('shorten_urls') and shorten_urls:
         regex = re.compile(
             r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
             re.IGNORECASE).findall(message)
         for url in regex:
             try:
                 message = message.replace(url, shorten(url))
             except:
                 pass
     if not self.config('text_decorations'):
         return self.clear_format(message)
     try:
         for special in self.special_chars:
             message = message.replace('{%s}' %
                                       special, self.special_chars[special])
         return message
     except:
         return self.clear_format(message)
Exemplo n.º 8
0
Arquivo: irc.py Projeto: kamaal44/Code
 def format(self, message, shorten_urls=True):
     '''
         formatting to support color/bold/italic/etc assignment
         and URL shortening in Codes responses
     '''
     message = uncharset(message)
     if self.config('shorten_urls') and shorten_urls:
         regex = re.compile(
             r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
             re.IGNORECASE).findall(message)
         for url in regex:
             try:
                 message = message.replace(url, shorten(url))
             except:
                 pass
     if not self.config('text_decorations'):
         return self.clear_format(message)
     try:
         for special in self.special_chars:
             message = message.replace('{%s}' % special,
                                       self.special_chars[special])
         return message
     except:
         return self.clear_format(message)