Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cre-ne-jp/rgrb into trpg_kancolle
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Aug 11, 2015
2 parents a0405bd + a3ddc10 commit 78114c1
Show file tree
Hide file tree
Showing 24 changed files with 709 additions and 131 deletions.
63 changes: 31 additions & 32 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.1)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
Expand All @@ -12,19 +12,19 @@ GEM
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
buftok (0.2.0)
cinch (2.2.5)
cinch (2.2.6)
coderay (1.1.0)
coveralls (0.7.12)
multi_json (~> 1.10)
coveralls (0.8.2)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.9.1)
simplecov (~> 0.10.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
crack (0.4.2)
safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.23)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.11)
faraday (0.9.1)
Expand All @@ -35,20 +35,19 @@ GEM
domain_name (~> 0.5)
http_parser.rb (0.6.0)
i18n (0.7.0)
json (1.8.2)
json (1.8.3)
lumberjack (1.0.9)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
mime-types (2.4.3)
minitest (5.5.1)
multi_json (1.11.0)
mime-types (2.6.1)
minitest (5.7.0)
multipart-post (2.0.0)
naught (1.0.0)
netrc (0.10.3)
parser (2.2.0.3)
parser (2.3.0.pre.2)
ast (>= 1.1, < 3.0)
powerpack (0.1.0)
powerpack (0.1.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -59,40 +58,40 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.2)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.1)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rubocop (0.29.1)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.32.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.1, < 3.0)
parser (>= 2.2.2.5, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)
safe_yaml (1.0.4)
simple_oauth (0.3.1)
simplecov (0.9.2)
simplecov (0.10.0)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
sysexits (1.2.0)
term-ansicolor (1.3.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.5)
tins (1.3.5)
tins (1.5.4)
twitter (5.14.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
Expand All @@ -108,7 +107,7 @@ GEM
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
unf_ext (0.0.7.1)
webmock (1.21.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ bundle install --deployment
| [ServerConnectionReport](doc/plugins/server_connection_report.md) | IRC サーバの接続状態の変化を報告する |
| [Part](doc/plugins/part.md) | チャンネルからの退出 |
| [KickBack](doc/plugins/kick_back.md) | RGRB が KICK されたとき、そのチャンネルに再度 JOIN する |
| [Invite](doc/plugins/invite.md) | RGRB が INVITE されたとき、そのチャンネルに JOIN する |

IRC ボットの起動
----------------
Expand Down
5 changes: 5 additions & 0 deletions config/invite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Invite プラグインの設定
Invite:
# JOIN 時に発言するメッセージ
JoinMessage:
- "ご招待いただきありがとう☆"
6 changes: 4 additions & 2 deletions config/rgrb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ Plugins:
- OnlineSessionSearch
- CreTwitterCitation
- CreBotHelp
- ServerConnectionReport
- ServerConnectionReport::Charybdis
- Part
- KickBack
- Invite

# 取り込む設定の ID を列挙する
# 設定ファイルは config/ 以下に配置する
# 設定 ID は config/ を基準とした相対パスから拡張子を除いたもの
Include:
- keyword
- cre_twitter_citation
- server_connection_report
- server_connection_report/charybdis
- part
- kick_back
- invite
5 changes: 0 additions & 5 deletions config/server_connection_report.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions config/server_connection_report/atheme_services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Atheme-Services 用サーバーリレー監視プラグインの設定
ServerConnectionReport::AthemeServices:
# NOTICE を行うチャンネルの一覧
ChannelsToSend:
- ''
15 changes: 15 additions & 0 deletions config/server_connection_report/charybdis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Charybdis 用サーバーリレー監視プラグインの設定
ServerConnectionReport::Charybdis:
# NOTICE を行うチャンネルの一覧
ChannelsToSend:
- ''

# 反応すべきメッセージの送信者の一覧
AllowedSenders:
- irc.cre.jp
- irc.r-roman.net
- services.cre.jp
- irc.egotex.net
- t-net.xyz
- irc.sougetu.net
- irc.kazagakure.net
5 changes: 5 additions & 0 deletions config/server_connection_report/ngircd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ngIRCd 用サーバーリレー監視プラグインの設定
ServerConnectionReport::Ngircd:
# NOTICE を行うチャンネルの一覧
ChannelsToSend:
- ''
24 changes: 24 additions & 0 deletions doc/plugins/invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Invite
======

RGRB が INVITE (招待)されたとき、そのチャンネルに JOIN するプラグインです。JOIN 時に特定のメッセージを発言することができます。

コマンド
--------

コマンドはありません。INVITE されたとき、自動的に動作します。

設定
----

設定ファイルに以下を追加して、プラグインの設定を行います。

```yaml
# Invite プラグインの設定
Invite:
# INVITE された時、JOIN 時に発言するメッセージ
JoinMessage:
- "ご招待いただきありがとう☆"
```

JoinMessage は、発言1行を1つの要素として、配列形式で記述してください。
63 changes: 59 additions & 4 deletions doc/plugins/server_connection_report.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,74 @@
ServerConnectionReport
======================

IRC サーバの接続状態の変化を報告するプラグインです。

接続先の「&SERVER」チャンネルに書き込まれるメッセージを監視して IRC サーバの接続状態の変化を検知しています。
IRC サーバの接続状態の変化を報告するプラグインです。お使いの IRC デーモンに合わせて有効化するものを選択してください。

設定
----

設定ファイルのプラグインリストに、以下のいずれかを追加します。

```yaml
Plugins:
- ServerConnectionReport::Ngircd
- ServerConnectionReport::Charybdis
- ServerConnectionReport::AthemeServices
```

以下で説明する、サーバの接続状態を報告するチャンネル(設定項目 `ChannelsToSend` で設定します)に JOIN しておかなければ、IRC サーバに発言が拒否されてプラグインが動作しないことがあります。


```yaml
IRCBot:
#### 省略 ####
# JOIN するチャンネルの一覧
Channels:
- '#cre'
```

報告先チャンネルのモードに +n(チャンネルに入っていないクライアントからの発言を拒否する)を設定しないことでも動作可能となりますが、スパムメッセージを許すことにつながりかねないため、推奨されません。

IRC デーモンごとの動作・設定
----------------------------

### ngIRCd

接続先の「&SERVER」チャンネルに書き込まれるメッセージを監視して IRC サーバの接続状態の変化を検知しています。

設定ファイルに以下を追加して、プラグインの設定を行います。

```yaml
# サーバーリレー監視プラグインの設定
ServerConnectionReport:
ServerConnectionReport::Ngircd:
# NOTICE を行なうチャンネルの一覧
ChannelsToSend:
- '#cre'
```

### Charybdis

charybdis は、初期設定では IRC サーバーオペレータ権(Oper)を持っている人に、サーバーメッセージで接続・切断などのステータスを送信するようになっています。このサーバーメッセージを検知します。

設定ファイルに以下を追加して、プラグインの設定を行います。

```yaml
# Charybdis 用サーバーリレー監視プラグインの設定
ServerConnectionReport::Charybdis:
# NOTICE を行うチャンネルの一覧
ChannelsToSend:
- '#cre'
```

### Atheme-Services

Atheme-Services を利用している環境であれば、IRC デーモンの種類を問わずこのプラグインでサーバーの接続状態を検知できます。初期設定では「#services」チャンネルに情報が出力されます。RGRB がこのチャンネルに参加している必要があります。

設定ファイルに以下を追加して、プラグインの設定を行います。

```yaml
# Atheme-Services 用サーバーリレー監視プラグインの設定
ServerConnectionReport::AthemeServices:
# NOTICE を行うチャンネルの一覧
ChannelsToSend:
- '#cre'
```
39 changes: 39 additions & 0 deletions lib/rgrb/plugin/invite/irc_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# vim: fileencoding=utf-8

require 'cinch'
require 'rgrb/plugin/configurable_adapter'

module RGRB
module Plugin
# INVITE されたとき、そのチャンネルに JOIN するプラグイン
module Invite
# Invite の IRC アダプター
class IrcAdapter
include Cinch::Plugin
include ConfigurableAdapter

set(plugin_name: 'Invite')
listen_to(:invite, method: :invite)

def initialize(*args)
super

config_data = config[:plugin] || {}
@join_message =
config_data['JoinMessage'] || [ 'ご招待いただきありがとう' ]
end

# 自分が INVITE されたら自動的にそのチャンネルに入る
# @param [Cinch::Message] m 送信されたメッセージ
# @return [void]
def invite(m)
Channel(m.channel).join
@join_message.each do |message|
m.target.send(message, true)
log("<JOIN on #{m.channel}> #{message}", :outgoing, :info)
end
end
end
end
end
end
Loading

0 comments on commit 78114c1

Please sign in to comment.