Skip to content

Commit

Permalink
Merge pull request #122 from cre-ne-jp/discord
Browse files Browse the repository at this point in the history
Discord 版の実装
  • Loading branch information
ochaochaocha3 committed Feb 24, 2019
2 parents 26d0d28 + 0728926 commit 2ed4989
Show file tree
Hide file tree
Showing 17 changed files with 1,290 additions and 44 deletions.
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source 'https://rubygems.org'

gem 'activesupport', '~> 5.0'
gem 'cinch'
gem 'twitter', '> 5.15'
gem 'lumberjack', '~> 1.0'
gem 'sysexits', '~> 1.2'
Expand All @@ -12,6 +11,14 @@ gem 'nokogiri', '~> 1.6'
gem 'd1lcs'
gem 'mail', '~> 2.7'

group :irc do
gem 'cinch'
end

group :discord do
gem 'discordrb'
end

group :development, :test do
gem 'pry', '~> 0.10'
gem 'yard', '~> 0.8'
Expand Down
34 changes: 32 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ GEM
safe_yaml (~> 1.0.0)
d1lcs (0.5.5)
diff-lcs (1.3)
discordrb (3.3.0)
discordrb-webhooks (~> 3.3.0)
ffi (>= 1.9.24)
opus-ruby
rbnacl (~> 3.4.0)
rest-client (>= 2.1.0.rc1)
websocket-client-simple (>= 0.3.0)
discordrb-webhooks (3.3.0)
rest-client (>= 2.1.0.rc1)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.11)
event_emitter (0.2.6)
ffi (1.10.0)
guess_html_encoding (0.0.11)
hashdiff (0.3.8)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (2.1.1)
Expand All @@ -49,13 +61,19 @@ GEM
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
multipart-post (2.0.0)
naught (1.1.0)
netrc (0.11.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
opus-ruby (1.0.1)
ffi
parallel (1.13.0)
parser (2.6.0.0)
ast (~> 2.4.0)
Expand All @@ -66,6 +84,13 @@ GEM
public_suffix (3.0.3)
rainbow (3.0.0)
rake (12.3.2)
rbnacl (3.4.0)
ffi
rest-client (2.1.0.rc1)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
Expand All @@ -79,7 +104,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.63.1)
rubocop (0.64.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
Expand Down Expand Up @@ -122,6 +147,10 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket (1.2.8)
websocket-client-simple (0.3.0)
event_emitter
websocket
yard (0.9.18)

PLATFORMS
Expand All @@ -133,6 +162,7 @@ DEPENDENCIES
cinch
coveralls
d1lcs
discordrb
guess_html_encoding
http (> 0.9)
lumberjack (~> 1.0)
Expand All @@ -148,4 +178,4 @@ DEPENDENCIES
yard (~> 0.8)

BUNDLED WITH
1.17.3
2.0.1
69 changes: 45 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,43 @@ gem install mailcatcher

### プラグイン一覧

#### IRC / Discord 欄の凡例

| 記号 | 意味 |
| ---- | ---- |
| o | 実装済み |
| x | 未実装 |
| - | 実装予定なし(チャット環境固有の物) |

#### オンラインセッション支援

| プラグイン名 | 内容 |
| ------------ | ---- |
| [DiceRoll](doc/plugins/dice_roll.md) | ダイスロール |
| [RandomGenerator](doc/plugins/random_generator.md) | ランダムジェネレータ |
| [Trpg::Detatoko](doc/plugins/trpg/detatoko.md) | 「でたとこサーガ」専用のダイス・表引きコマンド |
| [BCDice](doc/plugins/bcdice.md) | [ボーンズ&カーズ](https://github.com/torgtaitai/BCDice) のダイスコマンドを利用する |
| プラグイン名 | 内容 | IRC | Discord |
| ------------ | ---- | --- | ------- |
| [DiceRoll](doc/plugins/dice_roll.md) | ダイスロール | o | o |
| [RandomGenerator](doc/plugins/random_generator.md) | ランダムジェネレータ | o | o |
| [Trpg::Detatoko](doc/plugins/trpg/detatoko.md) | 「でたとこサーガ」専用のダイス・表引きコマンド | o | o |
| [BCDice](doc/plugins/bcdice.md) | [ボーンズ&カーズ](https://github.com/torgtaitai/BCDice) のダイスコマンドを利用する | o | o |

#### 情報検索・引用

| プラグイン名 | 内容 |
| ------------ | ---- |
| [Keyword](doc/plugins/keyword.md) | キーワード検索 |
| [OnlineSessionSearch](doc/plugins/online_session_search.md) | [TRPG.NET セッションマッチングシステム](http://session.trpg.net/)から予定されているオンラインセッションの情報を検索する |
| [CreTwitterCitation](doc/plugins/cre_twitter_citation.md) | Twitter @cre_ne_jp の引用 |
| [UrlFetchTitle](doc/plugins/url_fetch_title.md) | 発言された URL のページタイトルを取得する |

#### IRC 関連

| プラグイン名 | 内容 |
| ------------ | ---- |
| [CreBotHelp](doc/plugins/cre_bot_help.md) | クリエイターズネットワークの IRC ボットとしてのヘルプを表示する |
| [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 する |
| [Jihou](doc/plugins/jihou.md) | 毎日決まった時刻になった時、チャンネルに通知する |
| [Ctcp](doc/plugins/ctcp.md) | CTCP メッセージを受信した時、適切な応答を返す |
| プラグイン名 | 内容 | IRC | Discord |
| ------------ | ---- | --- | ------- |
| [Keyword](doc/plugins/keyword.md) | キーワード検索 | o | o |
| [OnlineSessionSearch](doc/plugins/online_session_search.md) | [TRPG.NET セッションマッチングシステム](http://session.trpg.net/)から予定されているオンラインセッションの情報を検索する | o | x |
| [CreTwitterCitation](doc/plugins/cre_twitter_citation.md) | Twitter @cre_ne_jp の引用 | o | - |
| [UrlFetchTitle](doc/plugins/url_fetch_title.md) | 発言された URL のページタイトルを取得する | o | - |

#### ユーティリティ

| プラグイン名 | 内容 | IRC | Discord |
| ------------ | ---- | --- | ------- |
| [CreBotHelp](doc/plugins/cre_bot_help.md) | クリエイターズネットワークの IRC ボットとしてのヘルプを表示する | o | o |
| [ServerConnectionReport](doc/plugins/server_connection_report.md) | IRC サーバの接続状態の変化を報告する | o | - |
| [Part](doc/plugins/part.md) | チャンネルからの退出 | o | - |
| [KickBack](doc/plugins/kick_back.md) | RGRB が KICK されたとき、そのチャンネルに再度 JOIN する | o | - |
| [Invite](doc/plugins/invite.md) | RGRB が INVITE されたとき、そのチャンネルに JOIN する | o | - |
| [Jihou](doc/plugins/jihou.md) | 毎日決まった時刻になった時、チャンネルに通知する | o | x |
| [Ctcp](doc/plugins/ctcp.md) | CTCP メッセージを受信した時、適切な応答を返す | o | - |

IRC ボットの起動
----------------
Expand All @@ -117,6 +125,19 @@ bin/rgrb-ircbot -c test # /path/to/rgrb/config/test.yaml を使用する場合

systemd による制御を行なう場合は [systemd](doc/system/systemd.md) を参照してください。

Discord ボットの招待
--------------------

[開発版の招待リンク](https://discordapp.com/oauth2/authorize?client_id=460671751181828097&scope=bot&permissions=3072&redirect_uri=https%3A%2F%2Fgithub.com%2Fcre-ne-jp%2Frgrb)

上のリンクをクリックすることで、Discord ボットを管理する Discord サーバに招待することが出来ます。
この場合、ご自身のコンピュータ上で RGRB をインストールしたり、RGRB を起動したりする必要はありません。

Discord ボットの起動
--------------------

(ToDo: 増補)

開発者向けドキュメントの生成
----------------------------

Expand Down
10 changes: 10 additions & 0 deletions bin/rgrb-discordbot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
# vim: fileencoding=utf-8

require 'rubygems'
require 'bundler/setup'

require 'rgrb/exec/discord_bot'

root_path = File.expand_path('..', File.dirname(__FILE__))
RGRB::Exec::DiscordBot.run(root_path, ARGV)
8 changes: 8 additions & 0 deletions config/rgrb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ IRCBot:
# 空文字列にすると、"Caught <signal>" が設定される
QuitMessage: 'bye'

# Discord ボットの設定
Discord:
# トークン
Token: ''

# クライアント ID
ClientID: ''

# 使用するプラグインを列挙する。大文字小文字を区別するので注意
Plugins:
- DiceRoll
Expand Down
4 changes: 4 additions & 0 deletions lib/rgrb/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Config
# IRC ボットの設定のハッシュ
# @return [Hash]
attr_reader :irc_bot
# Discord ボットの設定のハッシュ
# @return [Hash]
attr_reader :discord_bot
# プラグイン名の配列
# @return [Array<String>]
attr_reader :plugins
Expand Down Expand Up @@ -51,6 +54,7 @@ def load_yaml_file(config_id, root_path)
# @return [RGRB::Config]
def initialize(config_data)
@irc_bot = config_data['IRCBot']
@discord_bot = config_data['DiscordBot']
@plugins = config_data['Plugins'] || []
@plugin_config = {}

Expand Down
Loading

0 comments on commit 2ed4989

Please sign in to comment.