Reply with random object
For example, let's say I want to the bot to select one out of 2 images when it reads a certain word.
To accomplish this, I tried modelling after samples/random-reaction.yaml, specifically the random filter and combined it with my replymedia template. However, now my selection isn't a basic object anymore, but a dict whose value I need to access.
https://github.com/maubot/reactbot/blob/a1e5d2c87d84db64eb94e48b964039ea9af1655c/README.md?plain=1#L29-L30
This custom syntax does not appear to allow this in any way I tried, such as $${selection.url} or $${selection[url]} or $${selection['url']}.
Next I tried json, at which point I'm limited by having to use " double quotes for each key and value as well as the whole content being a string so the parser does not try to interpret it as yaml object. After failing with the usual escape syntax, I accomplished this by this syntax
content: >
{"key": "{{selection['value']}}"}
and other ways to access the dict, but again this does not appear to work, the jinja templated parts are simply empty.
Then I tried providing the whole object in the rule's variables and discard the reply field for now, but still failed with errors that I don't understand at this point, like AttributeError: 'CommentedSeq' object has no attribute 'items'.
- I would like the custom syntax to support subscription if possible.
- Where did I go wrong with jinja? Can you provide an example if this is possible?
- Where did I go wrong in my brute force approach? Is this currently possible at all?