]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/wheelfortune.rb
wheelfortune: start checking permissions
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / wheelfortune.rb
index d965409f66396276f7e7992540aa6a993618b248..07238cb0bc87083f09d5095ab242a122df7a00b7 100644 (file)
@@ -221,7 +221,11 @@ class WheelOfFortune < Plugin
       return
     end
     name = p[:name].to_s
-    name = @bot.config['wheelfortune.game_name'] if name.empty?
+    if name.empty?
+      name = m.source.get_botdata("wheelfortune.game_name") || @bot.config['wheelfortune.game_name']
+    else
+      m.source.set_botdata("wheelfortune.game_name", name.dup)
+    end
     @games[ch] = game = WoFGame.new(name, m.botuser, p[:single], p[:max])
     @bot.say chan, _("%{who} just created a new %{name} game to %{max} points (%{single} per question, %{price} per vowel)") % {
       :name => game.name,
@@ -245,6 +249,14 @@ class WheelOfFortune < Plugin
       return
     end
     game = @games[ch]
+
+    if m.botuser != game.manager and !m.botuser.permit?('wheelfortune::manage::other::add')
+      m.reply _("you can't add questions to the %{name} game on %{chan}") % {
+        :name => game.name,
+        :chan => p[:chan]
+      }
+    end
+
     cat = p[:cat].to_s
     clue = p[:clue].to_s
     ans = p[:ans].to_s
@@ -434,7 +446,12 @@ class WheelOfFortune < Plugin
       }
       return
     end
-    do_cancel(ch)
+    # is the botuser the manager or allowed to cancel someone else's game?
+    if m.botuser == game.manager or m.botuser.permit?('wheelfortune::manage::other::cancel')
+      do_cancel(ch)
+    else
+      m.reply _("you can't cancel the current game")
+    end
   end
 
   def do_cancel(ch)