summaryrefslogtreecommitdiff
path: root/lib/rbot/message.rb
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2009-01-21 16:49:31 +0100
committerdmitry kim <jason@nichego.net>2009-01-22 02:48:19 +0300
commit750f579b6ad2683abd50b51392e29dd1291d4d7e (patch)
tree0c88d517032dcbe495edff92a23ac245b1ef468e /lib/rbot/message.rb
parentec5745fa7abd47b8ca12bd783b0759079dff9917 (diff)
+ (reply) config option to force reply to query
+ (reply) symbol to bypass the config option * (plugins) fixed url according to the patch The symbols are: :to => :public force the message to be replied in channel (if any) :to => :private force the message to be replied in private :to => :auto takes core.private_replies (default)
Diffstat (limited to 'lib/rbot/message.rb')
-rw-r--r--lib/rbot/message.rb26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 8b650681..4da511ed 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -22,6 +22,10 @@ module Irc
:default => ':', :wizard => true,
:desc => "when replying with nick put this character after the nick of the user the bot is replying to"
)
+ Config.register BooleanValue.new('core.private_replies',
+ :default => false,
+ :desc => 'Should the bot reply to private instead of the channel?'
+ )
end
end
@@ -404,16 +408,32 @@ module Irc
# state if the nick of the user calling the command should be prepended
# :auto uses core.reply_with_nick
#
+ # :to [:private, :public, :auto]
+ # where should the bot reply?
+ # :private always reply to the nick
+ # :public reply to the channel (if available)
+ # :auto uses core.private_replies
+
def reply(string, options={})
- opts = {:nick => :auto}.merge options
+ opts = {:nick => :auto, :to => :auto}.merge options
+
if opts[:nick] == :auto
opts[:nick] = @bot.config['core.reply_with_nick']
end
- if (opts[:nick] && self.public? &&
+
+ if !self.public?
+ opts[:to] = :private
+ elsif opts[:to] == :auto
+ opts[:to] = @bot.config['core.private_replies'] ? :private : :public
+ end
+
+ if (opts[:nick] &&
+ opts[:to] != :private &&
string !~ /(?:^|\W)#{Regexp.escape(@source.to_s)}(?:$|\W)/)
string = "#{@source}#{@bot.config['core.nick_postfix']} #{string}"
end
- @bot.say @replyto, string, options
+ to = (opts[:to] == :private) ? source : @channel
+ @bot.say to, string, options
@replied = true
end