<commit_before># vim: fileencoding=utf-8

require 'rgrb/plugin_base/irc_adapter'

module RGRB
  module Plugin
    # CTCP 応答プラグイン
    module Ctcp
      # Ctcp の IRC アダプター
      class IrcAdapter
        include PluginBase::IrcAdapter

        set(plugin_name: 'Ctcp')
        ctcp(:clientinfo)
        ctcp(:version)
        ctcp(:time)
        ctcp(:ping)
        ctcp(:userinfo)
        ctcp(:source)

        def initialize(*args)
          super

          config_data = config[:plugin] || {}
          @userinfo = config_data['UserInfo'] || 'RGRB 稼働中'
          @valid_cmd = %w(CLIENTINFO VERSION TIME PING USERINFO SOURCE).sort
        end

        def ctcp_clientinfo(m)
          m.ctcp_reply(@valid_cmd.join(' '))
        end

        def ctcp_version(m)
          m.ctcp_reply("RGRB #{RGRB::VERSION}")
        end

        def ctcp_time(m)
          m.ctcp_reply(Time.now.strftime('%a %b %d %T %Y %Z'))
        end

        def ctcp_ping(m)
          m.ctcp_reply(m.ctcp_args.join(' '))
        end

        def ctcp_userinfo(m)
          m.ctcp_reply(@userinfo)
        end

        def ctcp_source(m)
          m.ctcp_reply('https://github.com/cre-ne-jp/rgrb')
        end
      end
    end
  end
end<commit_msg>fix-ctcp-plugin: IRC 版のプラグイン Ctcp を修正<commit_after># vim: fileencoding=utf-8

require 'rgrb/plugin_base/irc_adapter'

module RGRB
  module Plugin
    # CTCP 応答プラグイン
    module Ctcp
      # Ctcp の IRC アダプター
      class IrcAdapter
        include PluginBase::IrcAdapter

        set(plugin_name: 'Ctcp')
        ctcp(:clientinfo)
        ctcp(:version)
        ctcp(:time)
        ctcp(:ping)
        ctcp(:userinfo)
        ctcp(:source)

        def initialize(*args)
          super

          config_data = config[:plugin] || {}
          @userinfo = config_data['UserInfo'] || 'RGRB 稼働中'
          @valid_cmd = %w(CLIENTINFO VERSION TIME PING USERINFO SOURCE).sort
        end

        def ctcp_clientinfo(m)
          ctcp_reply(m, @valid_cmd.join(' '))
        end

        def ctcp_version(m)
          ctcp_reply(m, "RGRB #{RGRB::VERSION_WITH_COMMIT_ID}")
        end

        def ctcp_time(m)
          ctcp_reply(m, Time.now.strftime('%a, %d %b %Y %T %z'))
        end

        def ctcp_ping(m)
          ctcp_reply(m, m.ctcp_args.join(' '))
        end

        def ctcp_userinfo(m)
          ctcp_reply(m, @userinfo)
        end

        def ctcp_source(m)
          ctcp_reply(m, 'https://github.com/cre-ne-jp/rgrb')
        end

        private

        # CTCP 応答を返す
        # @param [Cinch::Message] m
        # @param [String] message 送信メッセージ
        # @return [void]
        def ctcp_reply(m, message)
          log_incoming(m)
          return if m.target.name == bot.nick

          m.ctcp_reply(message)
          log("<CTCP-reply to #{m.target.name}> #{message.inspect}", :outgoing, :info)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11354928596307906, 'fraction_numerical': 0.0006966213862765587, 'mean_word_length': 1.840751730959446, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '5918798', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1040, 'n_words': 197}