Class Irc::Bot::Auth::PermissionSet
In: lib/rbot/botuser.rb
Parent: Object
BasicUserMessage JoinMessage NamesMessage WhoisMessage ModeChangeMessage KickMessage MotdMessage QuitMessage BanlistMessage UserMessage NoSuchTargetMessage TopicMessage NickMessage WelcomeMessage UnknownMessage InviteMessage PartMessage NetmaskList UserList ArrayOf ChannelList Netmask User\n[lib/rbot/botuser.rb\nlib/rbot/irc.rb] Channel Singleton RfcCasemap StrictRfcCasemap AsciiCasemap Casemap PrivMessage NoticeMessage TokyoCabinet::BDB CIBDB Btree CIBtree Socket MessageQueue QueueRing Client DBHash\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] DBTree\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] Server NetmaskDb Bot\n[lib/rbot/botuser.rb\nlib/rbot/config.rb\nlib/rbot/ircbot.rb\nlib/rbot/language.rb\nlib/rbot/message.rb\nlib/rbot/messagemapper.rb\nlib/rbot/plugins.rb\nlib/rbot/rbotconfig.rb\nlib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] lib/rbot/ircsocket.rb lib/rbot/rfc2812.rb lib/rbot/registry/tc.rb lib/rbot/irc.rb lib/rbot/maskdb.rb lib/rbot/message.rb lib/rbot/messagemapper.rb lib/rbot/botuser.rb lib/rbot/registry/tc.rb (null) BotConfig PKGConfig ServerOrCasemap Irc dot/m_35_0.png

This class describes a permission set

Methods

Attributes

perm  [R] 

Public Class methods

Create a new (empty) PermissionSet

[Source]

     # File lib/rbot/botuser.rb, line 149
149:       def initialize
150:         @perm = {}
151:       end

Public Instance methods

Inspection simply inspects the internal hash

[Source]

     # File lib/rbot/botuser.rb, line 154
154:       def inspect
155:         @perm.inspect
156:       end

Tells if command cmd is permitted. We do this by returning the value of the deepest Command#path that matches.

[Source]

     # File lib/rbot/botuser.rb, line 181
181:       def permit?(str)
182:         cmd = str.to_irc_auth_command
183:         # TODO user-configurable list of always-allowed commands,
184:         # for admins that want to set permissions -* for everybody
185:         return true if cmd.command == :login
186:         allow = nil
187:         cmd.path.reverse.each { |k|
188:           if @perm.has_key?(k)
189:             allow = @perm[k]
190:             break
191:           end
192:         }
193:         return allow
194:       end

Resets the permission for command cmd

[Source]

     # File lib/rbot/botuser.rb, line 174
174:       def reset_permission(cmd)
175:         set_permission(cmd, nil)
176:       end

Sets the permission for command cmd to val,

[Source]

     # File lib/rbot/botuser.rb, line 160
160:       def set_permission(str, val)
161:         cmd = str.to_irc_auth_command
162:         case val
163:         when true, false
164:           @perm[cmd.command] = val
165:         when nil
166:           @perm.delete(cmd.command)
167:         else
168:           raise TypeError, "#{val.inspect} must be true or false" unless [true,false].include?(val)
169:         end
170:       end

[Validate]