cheogram/Adhoc.hs -rw-r--r-- 28.0 KiB
Include the command payload item along with the bot prompt
Change JID Command

If the backend sends us a command we recognize as a JID change, we
intercept it and replace it with ours.

Ours asks which JID we want to move to and then asks that JID if it
wants to do this. When they register we ask them to confirm they want to
swap, and then send the backend the actual JID change operation.
Log ad-hoc bot command error for debugging
Show Result Value with Newlines if Multiple Lines

I consolidated text-single and fixed into one method, and then also got
to use it for JID links.
Interpret Invalid Open List Numbers as Strings

This is a bit risky maybe, but previously if I was in the admin menu and
there I wanted to search by a phone number (that didn't start with +) or
a customer ID, I couldn't.

This is because the parser would intepret "4873278943" as an option I
wanted out of the numbered list, but that wasn't an option, so it would
ask me to pick another number.

Now instead I say if it's not a valid list, just pass it through as
More Datatypes in Result Forms

We previously assumed that only text fields would come back in results,
but that's no longer true. Some of them, like the "fixed" type would
work, but wouldn't look the same as they do when in an editable form,
whereas others like the list-single just didn't function at all.
Adhoc List Helper

This pulls some of the innards of the list processing out.
For now there's no good reason, but I'm about to use it to make a
display-only version.
AdHoc Bot Continues on Result Forms

Previously it would display results and then be done, but I may want to
display resutlts and then continue, so I pulled the logic out of the
normal form-filling path and put it in result so it will continue
automatically if we're still executing.

This means that the bot will render back-to-back result forms as just a
dump of their output, but honestly that's probably fine.
What's the point in asking if they'd like to continue if I can just
continue until we hit a question we actually need the human to answer!
Abstract DB

We want to change the storage backend, because we are pushing past the limits of
what is a good idea with TokyoCabinet and have had several corruption events.

So, as a first step, break the hard dependency of the main app code on
TokyoCabinet and instead express the operations in a more abstract data model.
This data model is pretty much based on Redis, which is the intended new storage
driver, but isn't directly tied to that either.
Support xdata-validate:open for list-single

This allows the user to enter any item the matches the datatype as well as
choose from the list.
Put cheogram provided commands last
Do not show command error on successful cancel
Do not show help text after cancel
Tell the user what the actions are when waiting at a note
Prioritize forms over notes
Send support contact addresses as part of help text, if available
Do not print hidden fields
Show var as label if there is not label
Print help at end of registration with bot