class Draw
Constants
- AGENT_MODEL
Public Class Methods
Source
# File plugins/draw.rb, line 21 def self.command_pattern /draw(?:\s+(.+))?$/i end
Source
# File plugins/draw.rb, line 31 def initialize(*) super DccImageHooks.on_image { |network:, nick:, entry:| handle_dcc_image(network: network, nick: nick, entry: entry) } end
Calls superclass method
Source
# File plugins/draw.rb, line 27 def self.parse_command(text, session_active: false) DrawSession.parse_command(text, session_active: session_active) end
Public Instance Methods
Source
# File plugins/draw.rb, line 36 def execute(m, args = nil) unless m.channel m.reply "Use !draw in a channel" return end network = bot.config.server nick = m.user.nick channel = m.channel.name session_active = DrawSession.session_active?(network: network, nick: nick, sessions: sessions_store) command = self.class.parse_command(args, session_active: session_active) return unless command if command[:action] == :stop result = DrawSession.stop_session(network: network, nick: nick, sessions: sessions_store) themed_flood_safe_reply(m, result[:message]) return end unless AiAccess.user_allowed?( channel: m.channel, user: m.user, network: network, nick: nick ) themed_flood_safe_reply(m, AiAccess.denial_message) return end case command[:action] when :error themed_flood_safe_reply(m, command[:message]) when :start DrawSession.begin_session( network: network, nick: nick, channel: channel, size: command[:size], sessions: sessions_store ) themed_flood_safe_reply(m, DrawSession.announce_message(size: command[:size])) when :start_with_style DrawSession.begin_session( network: network, nick: nick, channel: channel, style: command[:style], size: command[:size], sessions: sessions_store ) themed_flood_safe_reply(m, DrawSession.announce_message(style: command[:style], size: command[:size])) when :prompt run_prompt_async(m, prompt: command[:prompt], network: network, nick: nick, channel: channel) when :prompt_once run_prompt_once_async( m, prompt: command[:prompt], style: command[:style], size: command[:size], nick: nick ) end end
Source
# File plugins/draw.rb, line 86 def handle_dcc_image(network:, nick:, entry:) session = DrawSession.current_session(network: network, nick: nick, sessions: sessions_store) return unless session channel = bot.Channel(session[:channel]) return unless channel run_image_async( target: channel, network: network, nick: nick, channel: session[:channel], entry: entry, style: session[:style], size: session[:size], token: session[:token] ) rescue StandardError => e bot.loggers.error "Draw DCC hook failed: #{e.message}" end