[plugins/remember] Alternate usage available - set
Allows for directly setting data in the context With this and the (eval) type, i think config is now turing complete. lmao
This commit is contained in:
parent
d21238282c
commit
c18e47aec2
2 changed files with 14 additions and 2 deletions
ovtk_audiencekit/plugins/builtins
|
@ -22,3 +22,15 @@ class RememberPlugin(PluginBase):
|
|||
responses = responses[0]
|
||||
|
||||
_ctx[name] = responses
|
||||
|
||||
class SetPlugin(PluginBase):
|
||||
"""Set arbitrary data in the local context (can be fetched with the custom arg type)"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def run(self, _children=None, _ctx={}, **kwargs):
|
||||
for key, value in kwargs.items():
|
||||
if _ctx.get(key) is not None:
|
||||
self.logger.debug(f'Shadowing {key}')
|
||||
_ctx[key] = value
|
||||
|
|
|
@ -8,7 +8,7 @@ from .Chance import ChancePlugin as chance
|
|||
from .Choice import ChoicePlugin as choice
|
||||
from .Midi import MidiPlugin as midi
|
||||
from .WebSocket import WebSocketPlugin as ws
|
||||
from .Remember import RememberPlugin as remember
|
||||
from .Remember import RememberPlugin as remember, SetPlugin as set
|
||||
from .Scene import ScenePlugin as scene
|
||||
|
||||
__all__ = ['trigger', 'reply', 'command', 'cue', 'write', 'exec', 'chance', 'choice', 'midi', 'ws', 'remember', 'scene']
|
||||
__all__ = ['trigger', 'reply', 'command', 'cue', 'write', 'exec', 'chance', 'choice', 'midi', 'ws', 'remember', 'set', 'scene']
|
||||
|
|
Loading…
Add table
Reference in a new issue