Skip to content

Commit

Permalink
jihou-freewords: Jihou プラグインにおいて、任意のメッセージを出力できるようにした
Browse files Browse the repository at this point in the history
issue: #114
  • Loading branch information
koi-chan committed Oct 24, 2018
1 parent 35ab9a6 commit 3b8150d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config/jihou.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Jihou:
# 時報を発言する時間とチャンネル
Timer:
'00:00:00':
- '#irc_test'
'#irc_test': ''
'#irc_test': 'jihou-test'
11 changes: 8 additions & 3 deletions doc/plugins/jihou.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
Jihou
=====

定期的に決められた時刻が来たことを通知するプラグインです
決められた時刻が来たらメッセージを通知するプラグインです

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

コマンドはありません。設定ファイルで定義した時刻がやってきたとき、自動的に動作します。
メッセージ指定欄を空白にすると、時報として動作します。何か設定すると、そのメッセージを発言します。

時報は以下の書式の文章です。
\<nick> が \<channel> の皆様に \<yyyy>年\<mm>月\<dd>日 \<hh>時\<mm>分\<ss>秒 をお知らせします。

設定
----
Expand All @@ -17,10 +21,11 @@ Jihou
# 時報プラグインの設定
Jihou:
# 起動後、タイマーを動かさない時間(秒)。デフォルトは60秒
# チャンネルの情報などを取得するため、接続直後は発言が遅延するため
# チャンネルの情報などを取得するため、接続直後は発言が遅延する
Wait: 30
# 時報を発言する時間とチャンネル
Timer:
'00:00:00':
- '#irc_test'
'#irc_test': ''
'#irc_test': 'メッセージ'
```
13 changes: 8 additions & 5 deletions lib/rgrb/plugin/jihou/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,24 @@ def jihou
end

# 時報をチャンネルに発言する
# @param [String] channels 発言するチャンネル
# @param [Hash] channels 発言するチャンネル
# @param [Time] time 現在時刻
# @return [void]
def sendmes(channels, time)
channels.each { |channel_name|
channels.each do |channel_name, message|
channel = Channel(channel_name)

message = JIHOU_MESSAGE % {
if(message == '')
message = JIHOU_MESSAGE % {
nick: bot.nick,
channel: channel_name,
time: time.strftime('%Y年%m月%d日 %H時%M分%S秒')
}
}
end

channel.safe_notice(message)
log_notice(channel, message)
}
end
end
end
end
Expand Down

0 comments on commit 3b8150d

Please sign in to comment.