def autobutt(_, chan=None, msg=None, bot=None, say=None): butt_config = bot.config.get('butt', {}) rate_mean = butt_config.get('rate_mean', 300) rate_sigma = butt_config.get('rate_sigma', 60) lines_mean = butt_config.get('lines_mean', 20) now = time.time() if chan[0] == '#': # public channel if chan in channel_states: state = channel_states[chan] state.lines_left -= 1 if state.next_time > now: return sent, score = butter.score_sentence(msg) if score.sentence() == 0 or score.sentence() < state.lines_left: return say(butter.buttify_sentence(sent, score)) channel_states[chan] = ChannelState( random.normalvariate(rate_mean, rate_sigma) + now, poissonvariate(lines_mean) ) else: # private message try: say(butter.buttify(msg)) except: pass
def autobutt(_, chan=None, msg=None, bot=None, say=None): butt_config = bot.config.get('butt', {}) rate_mean = butt_config.get('rate_mean', 300) rate_sigma = butt_config.get('rate_sigma', 60) lines_mean = butt_config.get('lines_mean', 20) now = time.time() if chan[0] == '#': # public channel if chan in channel_states: state = channel_states[chan] state.lines_left -= 1 if state.next_time > now: return sent, score = butter.score_sentence(msg) if score.sentence() == 0 or score.sentence() < state.lines_left: return say(butter.buttify_sentence(sent, score)) channel_states[chan] = ChannelState( random.normalvariate(rate_mean, rate_sigma) + now, poissonvariate(lines_mean)) else: # private message try: say(butter.buttify(msg)) except: pass
def debutt(msg, me=None): """.debutt <text> -- provides debug butting info for a line of text""" sent, score = butter.score_sentence(msg) result = '' result += '{0}: '.format(score.sentence()) for i, word in enumerate(sent): if score.word(i) == 0: result += '-'.join(word) + '(0) ' else: result += '-'.join(word) + '({0}: {1}) '.format( score.word(i), score.syllable(i)) return result