summaryrefslogtreecommitdiff
path: root/lib/rbot/message.rb
diff options
context:
space:
mode:
authorAlex Legler <a3li@gentoo.org>2009-12-21 10:46:03 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-12-21 11:05:30 +0100
commit1a864cb7b90cc237e5af8f7fb8298d2efd46ee37 (patch)
tree3d9948ce32f01b5cdcbfe54ab1cc60fdc78b4a15 /lib/rbot/message.rb
parenta1db6671fb3819b58bcc1f0494b86d3a32df747f (diff)
message: Allow forcefully prepending of the nick when replying
Diffstat (limited to 'lib/rbot/message.rb')
-rw-r--r--lib/rbot/message.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index c13e59c1..ef2e14fe 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -403,19 +403,27 @@ module Irc
reply string, {:nick => true}.merge(options)
end
+ # Same as nickreply, but always prepend the target's nick.
+ def nickreply!(string, options={})
+ reply string, {:nick => true, :forcenick => true}.merge(options)
+ end
+
# The general way to reply to a command. The following options are available:
# :nick [false, true, :auto]
# state if the nick of the user calling the command should be prepended
# :auto uses core.reply_with_nick
#
+ # :forcenick [false, true]
+ # if :nick is true, always prepend the target's nick, even if the nick
+ # already appears in the reply. Defaults to false.
+ #
# :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, :to => :auto}.merge options
+ opts = {:nick => :auto, :forcenick => false, :to => :auto}.merge options
if opts[:nick] == :auto
opts[:nick] = @bot.config['core.reply_with_nick']
@@ -429,7 +437,8 @@ module Irc
if (opts[:nick] &&
opts[:to] != :private &&
- string !~ /(?:^|\W)#{Regexp.escape(@source.to_s)}(?:$|\W)/)
+ (string !~ /(?:^|\W)#{Regexp.escape(@source.to_s)}(?:$|\W)/ ||
+ opts[:forcenick]))
string = "#{@source}#{@bot.config['core.nick_postfix']} #{string}"
end
to = (opts[:to] == :private) ? source : @channel