+ def plainreply(string, options={})
+ reply string, {:nick => false}.merge(options)
+ end
+
+ # Same as reply, but when replying in public it adds the nick of the user
+ # the bot is replying to
+ def nickreply(string, options={})
+ reply string, {:nick => 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
+ #
+ # :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
+
+ if opts[:nick] == :auto
+ opts[:nick] = @bot.config['core.reply_with_nick']
+ end
+
+ 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
+ to = (opts[:to] == :private) ? source : @channel
+ @bot.say to, string, options
+ @replied = true
+ end
+
+ # convenience method to reply to a message with an action. It's the
+ # same as doing:
+ # <tt>@bot.action m.replyto, string</tt>
+ # So if the message is private, it will reply to the user. If it was
+ # in a channel, it will reply in the channel.
+ def act(string, options={})
+ @bot.action @replyto, string, options