module AiAccess
Constants
- DENIAL_MESSAGE
- REQUIRE_VOICE_ENV
Public Instance Methods
Source
# File lib/ai/access.rb, line 50 def channel_name(channel) channel.respond_to?(:name) ? channel.name : channel.to_s end
Source
# File lib/ai/access.rb, line 42 def channel_opped?(channel, user) channel.respond_to?(:opped?) && channel.opped?(user) end
Source
# File lib/ai/access.rb, line 46 def channel_voiced?(channel, user) channel.respond_to?(:voiced?) && channel.voiced?(user) end
Source
# File lib/ai/access.rb, line 16 def require_voice? value = ENV.fetch(REQUIRE_VOICE_ENV, "false").to_s.strip.downcase %w[1 true on yes].include?(value) end
Source
# File lib/ai/access.rb, line 21 def user_allowed?(channel:, user:, network:, nick: nil, irc: false) return false unless channel && user return true unless irc || require_voice? nick = nick || user.nick return true if channel_opped?(channel, user) return true if channel_voiced?(channel, user) RabbotDb.user_allowed_at_level?( network: network, channel: channel_name(channel), nick: nick, is_op: false, minimum: RabbotDb::LEVEL_VOICE ) end