<commit_before>require 'cinch'
require 'marky_markov'

module Cinch::Plugins
  class Outlander
    include Cinch::Plugin

    def initialize(*args)
      super
      @markov = MarkyMarkov::TemporaryDictionary.new
      @markov.parse_file "data/knowledge"
      @timer = Time.now
    end

    set :prefix, //
    match /outlander/
    listen_to :channel

    def execute(m)
      message_word_length = m.message.scan(' ').length
      max_reply_length = message_word_length > 40 ? 40 : message_word_length
      max_reply_length = 10 if max_reply_length < 10
      max_reply_length = max_reply_length * 2
      response = @markov.generate_n_words rand(10..max_reply_length)
      sleep(rand(2..6))
      m.reply response
    end

    def listen(m)
      if @timer + 60 < Time.now && rand(0..100) > 99
        @timer = Time.now
        execute(m)
      end
    end
  end
end<commit_msg>outlander plugin responds to bot name<commit_after>require 'cinch'
require 'marky_markov'

module Cinch::Plugins
  class Outlander
    include Cinch::Plugin

    def initialize(*args)
      super
      @markov = MarkyMarkov::TemporaryDictionary.new
      @markov.parse_file "data/knowledge"
      @timer = Time.now
    end

    set :prefix, //
    listen_to :channel

    def burp(m)
      message_word_length = m.message.scan(' ').length
      max_reply_length = message_word_length > 40 ? 40 : message_word_length
      max_reply_length = 10 if max_reply_length < 10
      max_reply_length = max_reply_length * 2
      response = (@markov.generate_n_words rand(10..max_reply_length)).split(' ').each { |word|
        random_number = rand(0..100)
        if random_number > 80
          word.upcase!
        elsif random_number < 20
          word.downcase!
        end
      }.join(' ')
      sleep(rand(2..6))
      m.reply response
    end

    def listen(m)
      if (@timer + 60 < Time.now && rand(0..100) > 99) || (m.message =~ /#{@bot.nick}/)
        @timer = Time.now
        burp(m)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10479041916167664, 'fraction_numerical': 0.0249500998003992, 'mean_word_length': 2.433219178082192, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '5191831', 'n_tokens_mistral': 707, 'n_tokens_neox': 653, 'n_words': 150}