class Ruboty::Action

Public Instance Methods

authorized!(message) click to toggle source
# File lib/ruboty/authorization.rb, line 21
def authorized!(message)
  @user_list = ::Ruboty::Authorization::UserList.new(message.robot.brain)

  return if [ self.name , owner_name ].include? message.from_name
  return if @user_list.find_by_name(message.from_name)

  raise AuthenticationError.new("#{message.from_name} is not authorized user")
end
call(handler, message, options = {}) click to toggle source
# File lib/ruboty/authorization.rb, line 11
def call(handler, message, options = {})
  return false unless !!options[:missing] == missing?
  return false unless message.match(pattern_with(handler.robot.name))

  authorized!(message)
  !!handler.send(name, message)
rescue => e
  message.reply(e.message) if reply_error?
end
owner_name() click to toggle source
# File lib/ruboty/authorization.rb, line 30
def owner_name
  ENV["OWNER_NAME"]
end
reply_error?() click to toggle source
# File lib/ruboty/authorization.rb, line 34
def reply_error?
  ENV['NOT_REPLY_AUTHORIZATION_ERROR'].nil?
end