]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/botuser.rb
auth.allow? method now informs a user when they don't have permissions
[user/henk/code/ruby/rbot.git] / lib / rbot / botuser.rb
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