Class: TelegramBotEngine::Authorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_bot_engine/authorizer.rb

Class Method Summary collapse

Class Method Details

.authorized?(username, bot: nil) ⇒ Boolean

Authorizes an inbound command username. ‘bot: nil` ⇒ global behavior, unchanged (docs/0001 §3.5). When a bot is given in :database mode, both global (nil bot_id) and that bot’s own allow entries apply.

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'lib/telegram_bot_engine/authorizer.rb', line 8

def self.authorized?(username, bot: nil)
  return true if TelegramBotEngine.config.allowed_usernames.nil?

  allowed = resolve_allowed_usernames(bot)
  allowed.map(&:downcase).include?(username&.downcase)
end