<commit_before># -*- coding: utf-8 -*-
"""
Created on May 04, 2014

@author: Tyranic-Moron
"""

from CommandInterface import CommandInterface
from IRCMessage import IRCMessage
from IRCResponse import IRCResponse, ResponseType

from twisted.words.protocols.irc import assembleFormattedText, attributes as A


class Rainbow(CommandInterface):
    triggers = ['rainbow', 'rrainbow']
    help = 'rainbow <text> - outputs the specified text with rainbow colours; rrainbow uses background colours'

    colours = [assembleFormattedText(A.fg.lightRed['']),
               #assembleFormattedText(A.fg.orange['']),
               assembleFormattedText(A.fg.yellow['']),
               assembleFormattedText(A.fg.lightGreen['']),
               assembleFormattedText(A.fg.lightCyan['']),
               assembleFormattedText(A.fg.lightBlue['']),
               assembleFormattedText(A.fg.lightMagenta['']),
               ]
    
    bgcolours = [assembleFormattedText(A.bg.red['']),
                 assembleFormattedText(A.bg.orange['']),
                 assembleFormattedText(A.bg.yellow['']),
                 assembleFormattedText(A.bg.green['']),
                 assembleFormattedText(A.bg.cyan['']),
                 assembleFormattedText(A.bg.blue['']),
                 assembleFormattedText(A.bg.magenta['']),
                 ]

    def execute(self, message):
        """
        @type message: IRCMessage
        """
        if len(message.ParameterList) == 0:
            return IRCResponse(ResponseType.Say, "You didn't give me any text to rainbow!", message.ReplyTo)

        outputMessage = u''

        if message.Command == 'rainbow':
            for i, c in enumerate(message.Parameters.decode('utf-8')):
                outputMessage += self.colours[i % len(self.colours)] + c
        else:
            for i, c in enumerate(message.Parameters.decode('utf-8')):
                outputMessage += self.bgcolours[i % len(self.bgcolours)] + c

        outputMessage += assembleFormattedText(A.normal[''])

        return IRCResponse(ResponseType.Say, outputMessage, message.ReplyTo)<commit_msg>[Rainbow] nevermind the unicode enumeration fix, I guess<commit_after># -*- coding: utf-8 -*-
"""
Created on May 04, 2014

@author: Tyranic-Moron
"""

from CommandInterface import CommandInterface
from IRCMessage import IRCMessage
from IRCResponse import IRCResponse, ResponseType

from twisted.words.protocols.irc import assembleFormattedText, attributes as A


class Rainbow(CommandInterface):
    triggers = ['rainbow', 'rrainbow']
    help = 'rainbow <text> - outputs the specified text with rainbow colours; rrainbow uses background colours'

    colours = [assembleFormattedText(A.fg.lightRed['']),
               #assembleFormattedText(A.fg.orange['']),
               assembleFormattedText(A.fg.yellow['']),
               assembleFormattedText(A.fg.lightGreen['']),
               assembleFormattedText(A.fg.lightCyan['']),
               assembleFormattedText(A.fg.lightBlue['']),
               assembleFormattedText(A.fg.lightMagenta['']),
               ]
    
    bgcolours = [assembleFormattedText(A.bg.red['']),
                 assembleFormattedText(A.bg.orange['']),
                 assembleFormattedText(A.bg.yellow['']),
                 assembleFormattedText(A.bg.green['']),
                 assembleFormattedText(A.bg.cyan['']),
                 assembleFormattedText(A.bg.blue['']),
                 assembleFormattedText(A.bg.magenta['']),
                 ]

    def execute(self, message):
        """
        @type message: IRCMessage
        """
        if len(message.ParameterList) == 0:
            return IRCResponse(ResponseType.Say, "You didn't give me any text to rainbow!", message.ReplyTo)

        outputMessage = u''

        if message.Command == 'rainbow':
            for i, c in enumerate(message.Parameters):
                outputMessage += self.colours[i % len(self.colours)] + c
        else:
            for i, c in enumerate(message.Parameters):
                outputMessage += self.bgcolours[i % len(self.bgcolours)] + c

        outputMessage += assembleFormattedText(A.normal[''])

        return IRCResponse(ResponseType.Say, outputMessage, message.ReplyTo)
{'fraction_non_alphanumeric': 0.12740213523131672, 'fraction_numerical': 0.004270462633451958, 'mean_word_length': 2.548821548821549, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2441083', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1194, 'n_words': 236}