<commit_before>class Hackbot::Conversation < ApplicationRecord
  after_initialize :default_values

  belongs_to :team, foreign_key: 'hackbot_team_id', class_name: ::Hackbot::Team

  validates :team, :state, presence: true

  def self.should_start?(_event)
    raise NotImplementedError
  end

  def is_part_of_convo?(event)
    # Don't react to events that we cause
    event[:user] != team.bot_user_id
  end

  def handle(event)
    next_state = send(state, event)

    self.state = if next_state.is_a? Symbol
                   next_state
                 else
                   :finish
                 end

    send(:finish, event) if state == :finish
  end

  protected

  def start(_event)
    raise notImplementedError
  end

  def finish(event); end

  def send_msg(channel, text)
    ::SlackClient::Chat.send_msg(channel, text, team.bot_access_token, as_user: true)
  end

  private

  def default_values
    self.state ||= :start
    self.data ||= {}
  end
end<commit_msg>Shorten line in Hackbot::Conversation<commit_after>class Hackbot::Conversation < ApplicationRecord
  after_initialize :default_values

  belongs_to :team, foreign_key: 'hackbot_team_id', class_name: ::Hackbot::Team

  validates :team, :state, presence: true

  def self.should_start?(_event)
    raise NotImplementedError
  end

  def is_part_of_convo?(event)
    # Don't react to events that we cause
    event[:user] != team.bot_user_id
  end

  def handle(event)
    next_state = send(state, event)

    self.state = if next_state.is_a? Symbol
                   next_state
                 else
                   :finish
                 end

    send(:finish, event) if state == :finish
  end

  protected

  def start(_event)
    raise notImplementedError
  end

  def finish(event); end

  def send_msg(channel, text)
    ::SlackClient::Chat.send_msg(
      channel,
      text,
      team.bot_access_token,
      as_user: true
    )
  end

  private

  def default_values
    self.state ||= :start
    self.data ||= {}
  end
end
{'fraction_non_alphanumeric': 0.08712871287128712, 'fraction_numerical': 0.0, 'mean_word_length': 2.7150735294117645, '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': '4492858', 'n_tokens_mistral': 662, 'n_tokens_neox': 630, 'n_words': 159}