jamesmeneghello / pynab

Newznab-compliant Usenet Indexer written in Python, using PostgreSQL/MySQL-like.
Other
209 stars 44 forks source link

Control codes are confusing the IRC prebot #279

Closed gkoh closed 8 years ago

gkoh commented 8 years ago

The nZEDbPRE channel appears to have started colourising and styling the IRC entries enough to confuse pynab's prebot. My prebot stopped processing any pres 5 days ago.

Looking through nZEDb's own IRC bot, I see a function call to _stripControlCharacters() which looks like this:

    /**
     * Strips control characters from a IRC message.
     *
     * @param string $text
     *
     * @return string
     *
     * @access protected
     */
    protected function _stripControlCharacters($text) {
        return preg_replace(
            array(
                '/(\x03(?:\d{1,2}(?:,\d{1,2})?)?)/',    // Color code
                '/\x02/',                               // Bold
                '/\x0F/',                               // Escaped
                '/\x16/',                               // Italic
                '/\x1F/',                               // Underline
                '/\x12/'                                // Device control 2
            ),
            '',
            $text
        );
    }

I believe the pynab IRC parser will need to do the same thing.

brookesy2 commented 8 years ago

I already submitted a fix for this. Its in the dev branch :)

https://github.com/Murodese/pynab/blob/development-postgres/pynab/pre.py#L41

gkoh commented 8 years ago

Aha, I was just looking into submitting my own fix for it, which is identical. Excellent!

This is a duplicate of #275.