Browse Source

Added the random pick subcommand

Kirk Trombley 5 years ago
parent
commit
034d14e1cc
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/plugins/watchlist.py

+ 7 - 1
src/plugins/watchlist.py

@@ -1,4 +1,5 @@
 import pickle
+import random
 
 from command_system import as_plugin, as_group_singleton, pop_arg
 
@@ -35,7 +36,12 @@ def add(args, data):
 
 
 def pick(args, data):
-    pass
+    items = data.get_items()
+    if len(items) == 0:
+        return "You have to add items before I can pick one!"
+    ind = random.randint(0, len(items) - 1)
+    chosen = items[ind]
+    return f"I have selected {ind + 1} - {chosen}! If you want to remove this from the list now, you can use !wlr {ind + 1}"
 
 
 def remove(args, data):