end\r
\r
\r
+ # This is the error that gets raised when an invalid password is met\r
+ #\r
+ class InvalidPassword < RuntimeError\r
+ end\r
+\r
+\r
# This is the basic class for bot users: they have a username, a password,\r
# a list of netmasks to match against, and a list of permissions.\r
#\r
str << ">"\r
end\r
\r
+ # In strings\r
+ def to_s\r
+ @username\r
+ end\r
+\r
# Convert into a hash\r
def to_hash\r
{\r
k = n.to_sym\r
raise "No such BotUser #{n}" unless include?(k)\r
if @botusers.has_key?(ircuser)\r
- return true if @botusers[ircuser].username = n\r
+ return true if @botusers[ircuser].username == n\r
# TODO\r
# @botusers[ircuser].logout(ircuser)\r
end\r
raise "Could not check permission for user #{user.inspect} to run #{cmdtxt.inspect} on #{chan.inspect}"\r
end\r
\r
- # Checks if command _cmd_ is allowed to User _user_ on _chan_\r
+ # Checks if command _cmd_ is allowed to User _user_ on _chan_, optionally\r
+ # telling if the user is authorized\r
+ #\r
def allow?(cmdtxt, user, chan=nil)\r
- permit?(user, cmdtxt, chan)\r
+ if permit?(user, cmdtxt, chan)\r
+ return true\r
+ else\r
+ # cmds = cmdtxt.split('::')\r
+ # @bot.say chan, "you don't have #{cmds.last} (#{cmds.first}) permissions here" if chan\r
+ @bot.say chan, "#{user}, you don't have '#{cmdtxt}' permissions here" if chan\r
+ return false\r
+ end\r
end\r
\r
end\r