All pastes #464843 Raw Edit

ryanakca

public python v1 · immutable
#464843 ·published 2007-04-29 19:11 UTC
rendered paste body
def formatter(sentence):    sentence = sentence.split # split the sentence into words.    formatted = ''        if sentence[0][0] == '#':     # If the first character of the first word is an "#",        # the formatted sentence now has the channelname.        formatted = formatted + sentence[0]            # the formatted sentence has 'channelname <b>&lt;' plus everything except                           # the first and last character of <nickname> + &gt;</b>'        formatted = formatted + ' <b>&lt;' + sentence[1][1:-1] + '<b>&gt; '         # Add everything that's left.        formatted = formatted + sentence[2:]        # inputed: #channelname <nick> message        # end product:   #channelname <b>&lt; nick &gt;</b> message    # the first character of the word isn't #, it's a nickname in privmsg    else:        # the formatted sentence has bold nick, plus everything else.        formatted = '<b>' + sentence[0] + '</b>' + sentence[1:]        # inputed: nick message        # end product: <b>nick</b> message    return formatted