<commit_before>require "ikku"
require "ruboty"

module Ruboty
  module Handlers
    class Kokodeikku < Base
      PREFIX = "ここで一句 "

      on(
        //,
        all: true,
        description: "ここで一句",
        name: "kokodeikku",
      )

      def kokodeikku(message)
        if !message.body.start_with?(PREFIX) && (phrases = reviewer.find(message.body))
          message.reply("#{PREFIX}#{phrases.map(&:join).join(' ')}")
        end
      end

      private

      def reviewer
        @reviewer ||= Ikku::Reviewer.new
      end
    end
  end
end
<commit_msg>Prevent to compose ikku from its own message<commit_after>require "ikku"
require "ruboty"

module Ruboty
  module Handlers
    class Kokodeikku < Base
      PREFIX = "ここで一句 "

      on(
        //,
        all: true,
        description: "ここで一句",
        name: "kokodeikku",
      )

      def kokodeikku(message)
        if message.from != robot.name && !message.body.start_with?(PREFIX) && (phrases = reviewer.find(message.body))
          message.reply("#{PREFIX}#{phrases.map(&:join).join(' ')}")
        end
      end

      private

      def reviewer
        @reviewer ||= Ikku::Reviewer.new
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12405699916177704, 'fraction_numerical': 0.0, 'mean_word_length': 2.0615384615384613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5429281', 'n_tokens_mistral': 423, 'n_tokens_neox': 405, 'n_words': 85}