소스 검색

Added the random pick subcommand

Kirk Trombley 5 년 전
부모
커밋
034d14e1cc
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  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):