Skip to content

Commit

Permalink
Part: 特定のチャンネルで .part コマンドを無効化できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Aug 23, 2015
1 parent f57ebc0 commit cd9fcba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/part.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Part:
# 退出時のメッセージ
# (IRCプロトコルにおける)PART コマンドの引数として使われます。
PartMessage: 'ご利用ありがとうございました'
# コマンドを無効化するチャンネル
ExcludeChannels:
- '#cre'
5 changes: 5 additions & 0 deletions doc/plugins/part.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Part

_NICK_ には、退出させたいボットのニックネームを入れます。アルファベットの大文字・小文字の違いは無視します。

このコマンドを無効化したいチャンネルがある場合、設定ファイルで指定することで例外的にプラグインを動作させないようにすることが可能です。

####

```
Expand All @@ -39,4 +41,7 @@ Part:
# 退出時のメッセージ
# (IRCプロトコルにおける) PART コマンドの引数として使われます。
PartMessage: 'ご利用ありがとうございました'
# コマンドを無効化するチャンネル
ExcludeChannels:
- '#cre'
```
6 changes: 6 additions & 0 deletions lib/rgrb/plugin/part/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ def initialize(*args)
config_data = config[:plugin] || {}
@part_message =
config_data['PartMessage'] || 'ご利用ありがとうございました'
@exclude_channels =
config_data['ExcludeChannels'].map do |channel|
channel.downcase
end
end

# コマンドを発言されたらそのチャンネルから退出する
# @param [Cinch::Message] m 送信されたメッセージ
# @param [String] nick 指定されたニックネーム
# @return [void]
def part(m, nick)
return if @exclude_channels.index(m.channel.name.downcase)

if !nick || nick.downcase == bot.nick.downcase
log(m.raw, :incoming, :info)
Channel(m.channel).part(@part_message)
Expand Down

0 comments on commit cd9fcba

Please sign in to comment.