jdev - 2023-11-01

  1. 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?

  2. singpolyma

    sxavier: are you looking to provide commands or trigger commands?

  3. sxavier


  4. 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?

  5. singpolyma

    yes, Cheogram Android shows ad hoc commands as a tab named "commands" in the chat when available

  6. sxavier

    Great, basically, I want to do something like what the @cheogram.com bot does

  7. singpolyma

    Ok, so a bot that exposes commands just like xmpp:cheogram.com ? Just checking because you said something about muc?

  8. sxavier

    Ideally, I'd like to do this in a MUC. Is that very different?

  9. sxavier

    I mean a small private group chat

  10. singpolyma

    As in the bot is a member of the MUC but people access the menu on the bot?

  11. singpolyma

    or you want the commands to show up on the MUC itself?

  12. sxavier

    I think I want the latter, but either could work if needed

  13. singpolyma

    What server are you using?

  14. ms-test


  15. sxavier

    Eventually, there might be two bots exposing commands if that's possible

  16. sxavier

    I'm using a hosted snikket

  17. 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

  18. 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

  19. sxavier

    Sounds like this is pushing the limits of what's easy to implement currently

  20. 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

  21. sxavier

    I tried implementing that and don't see anything on Cheogram Android

  22. 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

  23. sxavier

    Basically, I just loaded the plugin and called add_command()

  24. 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

  25. sxavier

    I'm not clear on how the handler function interacts

  26. sxavier

    Does it get a session passed to it?

  27. sxavier

    The doc lists Command's methods, but I don't see where the Command class comes into play

  28. 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

  29. singpolyma

    it returns a modified version of the dict

  30. singpolyma

    or just a new dict with a similar format I guess

  31. 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

  32. singpolyma

    and next/prev/cancel all optionally set to new handler functions if you have multiple steps

  33. sxavier

    Should I be looking at _process_command_response() to learn this?

  34. singpolyma

    that's where I'm looking

  35. 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...)

  36. 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

  37. sxavier

    It looked like there was a simpler case than the multi-step commands

  38. sxavier

    Are multi-step command most common?

  39. singpolyma

    if you don't need multi step just dont' return any of next/has_next etc

  40. singpolyma

    single step commands are quite fine for some cases if you don't need any user input

  41. 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 ^.^

  42. sxavier

    Would Cheogram Android display the "notes"?

  43. singpolyma


  44. sxavier

    Would I have seen an example of what that looks like in JMP?

  45. singpolyma

    cheogram android supports notes, data forms, and oob https urls in command flow

  46. 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!"

  47. sxavier

    That could work. Is there a separate XEP to show "info" command results?

  48. singpolyma

    you mean like the account info command?

  49. sxavier


  50. singpolyma

    that's a data form, but of type=result

  51. sxavier

    I'll put XEP-0004 on my reading list

  52. 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

  53. sxavier

    Sounds like my next task is to move to a 1-1 bot

  54. sxavier

    Is it possible to display an image in a data form?

  55. singpolyma

    that's probably the easiest way to start at least

  56. singpolyma

    yes, there are a few ways

  57. sxavier

    I assume it's not a good UI experience to send command results as a normal message?

  58. singpolyma

    probably you want https://xmpp.org/extensions/xep-0221.html which is image labels for data form fields

  59. singpolyma

    normally no

  60. sxavier


  61. 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

  62. 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

  63. 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.