Browse Source

Adding configuration fetch support to the as_plugin annot

Kirk Trombley 4 years ago
parent
commit
21cc7f01cf
1 changed files with 5 additions and 0 deletions
  1. 5 0
      lib/rollbot/plugins.py

+ 5 - 0
lib/rollbot/plugins.py

@@ -45,6 +45,11 @@ def get_converters(parameters, annotations):
             converters.append(lambda cmd, db, msg: cmd.bot)
         elif p in ("subc", "subcommand"):
             converters.append(lambda cmd, db, msg: RollbotMessage.from_subcommand(msg))
+        elif p in ("cfg", "config"):
+            converters.append(lambda cmd, db, msg: cmd.bot.config)
+        elif p.startswith("cfg") or p.endswith("cfg"):
+            annot = annotations.get(p, p)
+            converters.append(lambda cmd, db, msg: cmd.bot.config.get(annot))
         elif p.startswith("data") or p.endswith("data"):
             annot = annotations.get(p, p)
             converters.append(lambda cmd, db, msg, sing_cls=annot: sing_cls.get_or_create(db, msg))