-
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.
JOIN メッセージが複数行でも発言できるようにしてある
- Loading branch information
Showing
1 changed file
with
40 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,40 @@ | ||
# 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 |line| | ||
message = line.chomp | ||
m.target.send(message, true) | ||
log_notice(m.target, message) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |