-
sxavier
Is anyone aware of an example of XEP-0050 Ad-Hoc Commands (especially using slixmpp)? I saw readthedocs for slixmpp's xep-0050, but have a few questions. When using Ad-Hoc Commands on a MUC, should a particular bot's JID be the JID that exposes the ad-hoc command?
-
singpolyma
sxavier: are you looking to provide commands or trigger commands?
-
sxavier
Provide
-
sxavier
I'm embarassed to not know, but will clients like Cheogram Android show XEP-0050 Ad-Hoc Commands as a menu? Or is that a different XEP?
-
singpolyma
yes, Cheogram Android shows ad hoc commands as a tab named "commands" in the chat when available
-
sxavier
Great, basically, I want to do something like what the @cheogram.com bot does
-
singpolyma
Ok, so a bot that exposes commands just like xmpp:cheogram.com ? Just checking because you said something about muc?
-
sxavier
Ideally, I'd like to do this in a MUC. Is that very different?
-
sxavier
I mean a small private group chat
-
singpolyma
As in the bot is a member of the MUC but people access the menu on the bot?
-
singpolyma
or you want the commands to show up on the MUC itself?
-
sxavier
I think I want the latter, but either could work if needed
-
singpolyma
What server are you using?
-
ms-test
test
-
sxavier
Eventually, there might be two bots exposing commands if that's possible
-
sxavier
I'm using a hosted snikket
-
singpolyma
you may find https://modules.prosody.im/mod_muc_adhoc_bots.html interesting -- it's prosody, but experimental so very much not a part of snikket right now
-
singpolyma
If you want the bots to instead show up as participants in the room and then members can access the menu on them somehow, this is also allowed by the protocol. Gajim seems to support it in a quick check just now, cheogram android doesn't yet but I've been meaning to think of a UI for that
-
sxavier
Sounds like this is pushing the limits of what's easy to implement currently
-
singpolyma
I any case you were actually asking about https://slixmpp.readthedocs.io/en/latest/api/plugins/xep_0050.html which looks ok. You can leave the jid as None and it will fill it in for you normally. For the participant-in-MUC case I'm not sure what's best... could still use None and probably that's fine? Especially in a non-anonymous room. Otherwise you can explicily pass your MUC full jid. I haven't tested this use case a lot yet but it's on my radar as I said
-
sxavier
I tried implementing that and don't see anything on Cheogram Android
-
singpolyma
sxavier: a 1:1 bot like cheogram.com is easy and will work everywhere that has even halfway ad hoc support. For on-muc commands the muc service needs support somehow, which I what I wrote that prosody module to make easy. For a muc participant gajim definitely has some support but I'm not sure about anything else right now
-
sxavier
Basically, I just loaded the plugin and called add_command()
-
singpolyma
sxavier: with a 1:1 bot conversation? You need to make sure you also are exposing caps (slixmpp probably does this for you ?) and that cheogram android sees you as online (so make sure added to roster etc) or else use the "refresh feature discovery" option under three dots
-
sxavier
I'm not clear on how the handler function interacts
-
sxavier
Does it get a session passed to it?
-
sxavier
The doc lists Command's methods, but I don't see where the Command class comes into play
-
singpolyma
I am reading the code now. Looks like handler gets first two arguments, the incoming iq stanza of the command execute and a dict representing the session
-
singpolyma
it returns a modified version of the dict
-
singpolyma
or just a new dict with a similar format I guess
-
singpolyma
with payload set to the xml children to return (usuall a data form) and/or notes set to some strings to display to the user as notes
-
singpolyma
and next/prev/cancel all optionally set to new handler functions if you have multiple steps
-
sxavier
Should I be looking at _process_command_response() to learn this?
-
singpolyma
that's where I'm looking
-
singpolyma
it looks like it has some edge case bugs, but probably nothing you'll run into (for example it assume it is completed if there is no next handler... even if there is a complete or a prev handler? and then it wants these has_next or allow_prev booleans even if a handler is specified...)
-
singpolyma
also it ignores allow_prev if you don't have_next? So you can't make a completed step you can go back from. edge cases like this
-
sxavier
It looked like there was a simpler case than the multi-step commands
-
sxavier
Are multi-step command most common?
-
singpolyma
if you don't need multi step just dont' return any of next/has_next etc
-
singpolyma
single step commands are quite fine for some cases if you don't need any user input
-
singpolyma
I'm not a good barometer for common since I'm out here pushing the envelope on what ad hoc commands can do on a regular basis ^.^
-
sxavier
Would Cheogram Android display the "notes"?
-
singpolyma
yes
-
sxavier
Would I have seen an example of what that looks like in JMP?
-
singpolyma
cheogram android supports notes, data forms, and oob https urls in command flow
-
singpolyma
sxavier: sure, if you use the "configure calls" command the first step is a data form, but if you push next you get a note that says "configuration saved!"
-
sxavier
That could work. Is there a separate XEP to show "info" command results?
-
singpolyma
you mean like the account info command?
-
sxavier
yes
-
singpolyma
that's a data form, but of type=result
-
sxavier
I'll put XEP-0004 on my reading list
-
singpolyma
you may also find this interesting, though it's probably about more advanced cases than you care about https://wiki.soprani.ca/CheogramApp/CommandUI
-
sxavier
Sounds like my next task is to move to a 1-1 bot
-
sxavier
Is it possible to display an image in a data form?
-
singpolyma
that's probably the easiest way to start at least
-
singpolyma
yes, there are a few ways
-
sxavier
I assume it's not a good UI experience to send command results as a normal message?
-
singpolyma
probably you want https://xmpp.org/extensions/xep-0221.html which is image labels for data form fields
-
singpolyma
normally no
-
sxavier
Ah
-
sxavier
I wish I knew more about XMPP when I started designing the project. This conversation has been super helpful. Let us know if you ever do a webinar on writing bots or gateways
-
singpolyma
If you start with 1:1 that's probably good just to get your feet wet or whatever because it's the easisest to test etc. I'm very curious about your use case and how we can make the things you want to do easier to acheive
-
sxavier
I've been working on MUC bots for the past year because I needed it for a simple gateway. Then I started adding bots for other specific tasks, so I haven't put any time into 1-1 code.