class XNM::Telegram::OnCommand

Attributes

deny_message[RW]
required_perms[RW]

Public Class Methods

new(options) click to toggle source
Calls superclass method XNM::Telegram::OnTelegramEvent::new
# File lib/xnm/telegram/OnCommand.rb, line 9
def initialize(options)
        super()

        @block = options[:block]
        @command = options[:command]

        @required_perms = [options[:permissions]].flatten.uniq

        @deny_message = options[:deny_msg] || 'You are not authorized, %s.'

        @priority += 5
end

Public Instance Methods

nomp_message(message) click to toggle source
# File lib/xnm/telegram/OnCommand.rb, line 22
def nomp_message(message)
        return if message.handled
        return unless message.command == @command

        if message.user.has_permissions? @required_perms
                @block.call message
        else
                message.reply @deny_message % [message.user.casual_name]
        end
end