-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
退出コマンドが発言されたとき、そのチャンネルから PART するプラグインを追加した。
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Part | ||
==== | ||
|
||
コマンドを発言されたとき、そのチャンネルから退出するプラグインです。 | ||
|
||
コマンド | ||
-------- | ||
|
||
### チャンネルからの退出 (`.part` / `.part-NICK`) | ||
|
||
どちらのコマンドもチャンネルから退出するという機能に違いはありません。 | ||
そのチャンネルに複数の `.part` コマンドに反応するボットがいた時に、ニックネームを指定して退出させるために、後者のコマンドも用意されています。 | ||
|
||
_NICK_ には、退出させたいボットのニックネームを入れます。 | ||
アルファベットの大文字・小文字の違いは無視します。 | ||
|
||
#### 例 | ||
|
||
``` | ||
.part | ||
.part-rgrb (ニックネームが "rgrb" の場合) | ||
``` | ||
|
||
設定 | ||
---- | ||
|
||
設定ファイルに以下を追加して、プラグインの設定を行います。 | ||
|
||
```yaml | ||
# 退出プラグインの設定 | ||
Part: | ||
# 退出時のメッセージ | ||
# (IRCプロトコルにおける) PART コマンドの引数として使われます。 | ||
PartMessage: 'config-part message' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# vim: fileencoding=utf-8 | ||
|
||
require 'cinch' | ||
require 'rgrb/plugin/configurable_adapter' | ||
|
||
module RGRB | ||
module Plugin | ||
module Part | ||
# Part の IRC アダプター | ||
class IrcAdapter | ||
include Cinch::Plugin | ||
include ConfigurableAdapter | ||
|
||
set(plugin_name: 'Part') | ||
match(/part/, method: :part) | ||
match(/part-(\w+)/, method: :part) | ||
|
||
def initialize(*args) | ||
super | ||
|
||
config_data = config[:plugin] | ||
@part_message = config_data['PartMessage'] | ||
end | ||
|
||
# コマンドを発言されたらそのチャンネルから退出する | ||
# @return [void] | ||
def part(m, nick = nil) | ||
if nick == m.bot.to_s || nick == nil | ||
Channel(m.channel).part(@part_message) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |