class CharacterResponder
Public Class Methods
Source
# File plugins/character_responder.rb, line 30 def self.command_for_bot?(message, bot) nick_candidates(bot).any? { |nick| CharacterMention.command_for_bot?(message, nick) } end
Source
# File plugins/character_responder.rb, line 18 def self.enabled?(network:, channel:, default: true) BotOptions.boolean(network: network, channel: channel, key: "respond_on_mention", default: default) end
Source
# File plugins/character_responder.rb, line 26 def self.mentioned?(message, bot) CharacterMention.mentioned_any?(message, nick_candidates(bot)) end
Source
# File plugins/character_responder.rb, line 22 def self.nick_candidates(bot) ([bot.nick, bot.config.nick] + Array(bot.config.nicks)).compact.uniq end
Source
# File plugins/character_responder.rb, line 34 def self.reply_for(profile:, role:, random: Random) return AthfRabbot.random_quote(rng: random) if role.to_s == "athf_rabbot" CharacterMention.profile_reply(profile, random: random) || "I'm here." end
Public Instance Methods
Source
# File plugins/character_responder.rb, line 40 def respond_to_mention(m) return unless m.channel return if m.user.nick == bot.nick return if ChatModeRegistry.active?(m.channel.name) return if self.class.command_for_bot?(m.message, bot) return unless self.class.mentioned?(m.message, bot) return unless self.class.enabled?(network: bot.config.server, channel: m.channel.name) role = bot.config.shared[:bot_role].to_s profile = bot.config.shared[:character_profile] return if role.empty? && profile.nil? safe_reply(m, self.class.reply_for(profile: profile, role: role)) end