Skip to content

Commit

Permalink
Logging: JOIN/PART のログへの残しかたを統一
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Jan 25, 2017
1 parent b93eeee commit f4a5285
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/rgrb/plugin/invite/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def initialize(*args)
# @return [void]
def invite(m)
Channel(m.channel).join
log_join(m.channel)
notice_multi_lines(@join_message, m.channel)
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/rgrb/plugin/kick_back/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def kick(m)
if m.params[1].downcase == bot.nick.downcase
log_incoming(m)
Channel(m.channel).join
log_join(m.channel)
m.target.send(@join_message, true)
log("<JOIN on #{m.channel}> #{@join_message}", :outgoing, :info)
log_notice(m.channel, @join_message)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rgrb/plugin/part/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def part(m, nick)
log_notice(m.target, @locked_message)
else
Channel(m.channel).part(@part_message)
log("<PART from #{m.channel}> #{@part_message}", :outgoing, :info)
log_part(m.channel, @part_message)
end
end
end
Expand Down
20 changes: 16 additions & 4 deletions lib/rgrb/plugin/util/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@ def log_incoming(m)
# @param [String] message メッセージ
# @return [void]
def log_notice(target, message)
log(
"<NOTICE to #{target.name}> #{message.inspect}",
:outgoing, :info
)
log("<NOTICE to #{target.name}> #{message.inspect}", :outgoing, :info)
end

# JOIN をログに残す
# @param [Cinch::Channel] channel
# @return [void]
def log_join(channel)
log("<JOIN on #{channel}>", :outgoing, :info)
end

# PART をログに残す
# @param [Cinch::Channel] channel
# @param [String] message 退出メッセージ
# @return [void]
def log_part(channel, message)
log("<PART from #{channel}> #{message.inspect}", :outgoing, :info)
end
end
end
Expand Down

0 comments on commit f4a5285

Please sign in to comment.