]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
auth.allow? method now informs a user when they don't have permissions
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 11 Aug 2006 08:49:10 +0000 (08:49 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 11 Aug 2006 08:49:10 +0000 (08:49 +0000)
ChangeLog
lib/rbot/botuser.rb

index 82614afcf97b1b8021d51f6e0d07439fd73b6266..9efe9b08090353debbabf58aaa58f55b1292e5bd 100644 (file)
--- 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>
 
index cc9e01a58f2608b996a436f83f50f2bbece89d56..7daaf66e9cf7d3baf3cb8d003618e67d71ccf6d1 100644 (file)
@@ -193,6 +193,11 @@ module Irc
         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
@@ -652,9 +657,18 @@ module Irc
         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