class ChatMode
Public Class Methods
Source
# File plugins/chat_mode.rb, line 31 def self.active?(channel) ChatModeRegistry.active?(channel) end
Source
# File plugins/chat_mode.rb, line 35 def self.admin_allowed?(network:, channel:, nick:, is_op:) RabbotDb.user_allowed_at_level?( network: network, channel: channel, nick: nick, is_op: is_op, minimum: RabbotDb::LEVEL_ADMIN ) end
Source
# File plugins/chat_mode.rb, line 45 def self.responds_to_command?(bot) BotIdentity.room_reader_bot?(bot) end
Public Instance Methods
Source
# File plugins/chat_mode.rb, line 49 def execute(m, args = nil) return unless m.channel return unless self.class.responds_to_command?(bot) network = bot.config.server channel = m.channel.name RabbotUser.seed_channel_defaults(network: network, channel: channel) unless chat_enabled?(channel) m.reply "Chat mode is disabled in this channel." return end max_minutes = max_minutes_for(channel) parsed = ChatModeSession.parse_command(args, max_minutes: max_minutes) if parsed[:error] m.reply parsed[:error] return end case parsed[:action] when :status state = ChatModeRegistry.get(channel, network: network) m.reply ChatModeSession.format_status(state, bot_nick: bot.nick) when :stop, :pause, :continue handle_control(m, parsed[:action]) when :start handle_start(m, parsed) end end
Source
# File plugins/chat_mode.rb, line 24 def on_connect(_m) network = bot.config.server bot.config.channels.each do |channel| ChatModeRegistry.delete(channel, network: network) end end