Skip to content

Commit

Permalink
利用可能なCTCPコマンドをクラス定数で定義する
Browse files Browse the repository at this point in the history
一箇所で定義して漏れが発生しないようにする
  • Loading branch information
ochaochaocha3 committed Sep 26, 2019
1 parent b32ae5c commit 40a26f9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/rgrb/plugin/ctcp/irc_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# vim: fileencoding=utf-8

require 'rgrb/plugin_base/irc_adapter'
Expand All @@ -11,23 +12,25 @@ class IrcAdapter
include PluginBase::IrcAdapter

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

# 利用可能な CTCP コマンド
AVAILABLE_COMMANDS = %w(CLIENTINFO VERSION TIME PING USERINFO SOURCE)
.sort
.freeze

AVAILABLE_COMMANDS.each do |command|
ctcp(command)
end

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(' '))
ctcp_reply(m, AVAILABLE_COMMANDS.join(' '))
end

def ctcp_version(m)
Expand Down

0 comments on commit 40a26f9

Please sign in to comment.