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 "#", formatted = formatted + sentence[0] # the formatted sentence has the channelname. formatted = formatted + ' <b><' + sentence[1][1:-1] + '<b>> ' # the formatted sentence has 'channelname <b><' plus everything except # the first and last character of <nickname> + ></b>' formatted = formatted + sentence[2:] # Add everything that's left. # inputed: #channelname <nick> message # end product: #channelname <b>< nick ></b> message else: # the first character of the word isn't #, it's a nickname in privmsg formatted = '<b>' + sentence[0] + '</b>' + sentence[1:] # the formatted sentence has bold nick, plus everything else. # inputed: nick message # end product: <b>nick</b> message return formatted