summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-11 08:49:10 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-11 08:49:10 +0000
commit98066bb754014b343dea272ebf6ec22babf9e8bf (patch)
treee5100449897579c4f5558e145a052ebdc5b48974
parente90a6ac1e600db1a6b19c56532e4a1f268455a8b (diff)
auth.allow? method now informs a user when they don't have permissions
-rw-r--r--ChangeLog2
-rw-r--r--lib/rbot/botuser.rb18
2 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 82614afc..9efe9b08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
* AutoOp plugin: adapted to the new IRC framework.
* AutoOp plugin: trigger autoop on nick change too.
+ * New Auth Framework: allow? method now informs a user when they don't
+ have permission to do what they asked for.
2006-08-10 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb
index cc9e01a5..7daaf66e 100644
--- a/lib/rbot/botuser.rb
+++ b/lib/rbot/botuser.rb
@@ -193,6 +193,11 @@ module Irc
str << ">"
end
+ # In strings
+ def to_s
+ @username
+ end
+
# Convert into a hash
def to_hash
{
@@ -652,9 +657,18 @@ module Irc
raise "Could not check permission for user #{user.inspect} to run #{cmdtxt.inspect} on #{chan.inspect}"
end
- # Checks if command _cmd_ is allowed to User _user_ on _chan_
+ # Checks if command _cmd_ is allowed to User _user_ on _chan_, optionally
+ # telling if the user is authorized
+ #
def allow?(cmdtxt, user, chan=nil)
- permit?(user, cmdtxt, chan)
+ if permit?(user, cmdtxt, chan)
+ return true
+ else
+ # cmds = cmdtxt.split('::')
+ # @bot.say chan, "you don't have #{cmds.last} (#{cmds.first}) permissions here" if chan
+ @bot.say chan, "#{user}, you don't have '#{cmdtxt}' permissions here" if chan
+ return false
+ end
end
end