<commit_before>require "logstash/outputs/base"
require "logstash/namespace"
require "thread"

# Write events to IRC
#
class LogStash::Outputs::Irc < LogStash::Outputs::Base

  config_name "irc"
  milestone 1

  # Address of the host to connect to
  config :host, :validate => :string, :required => true

  # Port on host to connect to.
  config :port, :validate => :number, :default => 6667

  # IRC Nickname
  config :nick, :validate => :string, :default => "logstash"

  # IRC Username
  config :user, :validate => :string, :default => "logstash"

  # IRC Real name
  config :real, :validate => :string, :default => "logstash"

  # IRC server password
  config :password, :validate => :password

  # Channels to broadcast to.
  # 
  # These should be full channel names including the '#' symbol, such as
  # "#logstash".
  config :channels, :validate => :array, :required => true

  # Message format to send, event tokens are usable here
  config :format, :validate => :string, :default => "%{message}"

  # Set this to true to enable SSL.
  config :secure, :validate => :boolean, :default => false

  # Limit the rate of messages sent to IRC in messages per second.
  config :messages_per_second, :validate => :number, :default => 0.5

  public
  def register
    require "cinch"
    @irc_queue = Queue.new
    @logger.info("Connecting to irc server", :host => @host, :port => @port, :nick => @nick, :channels => @channels)

    @bot = Cinch::Bot.new
    @bot.loggers.clear
    @bot.configure do |c|
      c.server = @host
      c.port = @port
      c.nick = @nick
      c.user = @user
      c.realname = @real
      c.channels = @channels
      c.password = <PASSWORD>
      c.ssl.use = @secure
      c.messages_per_second = @messages_per_second if @messages_per_second
    end
    Thread.new(@bot) do |bot|
      bot.start
    end
  end # def register

  public
  def receive(event)
    return unless output?(event)
    @bot.channels.each do |channel|
      channel.msg(event.sprintf(@format))
    end # channels.each
  end # def receive
end # class LogStash::Outputs::Irc<commit_msg>- only compute message once<commit_after>require "logstash/outputs/base"
require "logstash/namespace"
require "thread"

# Write events to IRC
#
class LogStash::Outputs::Irc < LogStash::Outputs::Base

  config_name "irc"
  milestone 1

  # Address of the host to connect to
  config :host, :validate => :string, :required => true

  # Port on host to connect to.
  config :port, :validate => :number, :default => 6667

  # IRC Nickname
  config :nick, :validate => :string, :default => "logstash"

  # IRC Username
  config :user, :validate => :string, :default => "logstash"

  # IRC Real name
  config :real, :validate => :string, :default => "logstash"

  # IRC server password
  config :password, :validate => :password

  # Channels to broadcast to.
  # 
  # These should be full channel names including the '#' symbol, such as
  # "#logstash".
  config :channels, :validate => :array, :required => true

  # Message format to send, event tokens are usable here
  config :format, :validate => :string, :default => "%{message}"

  # Set this to true to enable SSL.
  config :secure, :validate => :boolean, :default => false

  # Limit the rate of messages sent to IRC in messages per second.
  config :messages_per_second, :validate => :number, :default => 0.5

  public
  def register
    require "cinch"
    @irc_queue = Queue.new
    @logger.info("Connecting to irc server", :host => @host, :port => @port, :nick => @nick, :channels => @channels)

    @bot = Cinch::Bot.new
    @bot.loggers.clear
    @bot.configure do |c|
      c.server = @host
      c.port = @port
      c.nick = @nick
      c.user = @user
      c.realname = @real
      c.channels = @channels
      c.password = <PASSWORD> rescue nil
      c.ssl.use = @secure
      c.messages_per_second = @messages_per_second if @messages_per_second
    end
    Thread.new(@bot) do |bot|
      bot.start
    end
  end # def register

  public
  def receive(event)
    return unless output?(event)
    @logger.debug("Sending message to channels", :event => event)
    text = event.sprintf(@format)
    @bot.channels.each do |channel|
      @logger.debug("Sending to...", :channel => channel, :text => text)
      channel.msg(text)
    end # channels.each
  end # def receive
end # class LogStash::Outputs::Irc
{'fraction_non_alphanumeric': 0.12826984855438275, 'fraction_numerical': 0.0032124827902707664, 'mean_word_length': 3.2361516034985423, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 54, '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': '4794235', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1363, 'n_words': 447}