(To be clear, since I realized just now that to non-devs the title might be misleading: This feature does not add AI bots to your comments plugin by default! The comments plugin and the AI plugins are completely distinct. But plugins can of course interact with one another, and this new feature of the comments plugin allows for some interesting interactions - the title just gives one of those as a fun example.)

You can now “programmatically” submit comments on behalf of the user, and you can also get/set the contents of the input text box.

If a comment was programmatically submitted, then a little icon is shown on the comment to indicate that the user didn’t personally click the submit button.

This feature, used alongside the onComment/onLoad feature can e.g. be used to create an AI bot that “lives in” your comments box, or create a multiplayer game of chess, or maybe add an auto-error-report log using window.onerror, and so on.

Edit: Also, you can now use c.comments to get an array/list of the comments - but make sure to do that only after onLoad has triggered, since c.comments only returns loaded comments - so if comments box hasn’t loaded yet, you’ll get an empty array.

Let me know if you find any bugs/issues!

https://perchance.org/programmatic-get-set-submit-comments-plugin-example#edit

I’ll probably create a little AI bot example at some point, but you’re welcome to beat me to it! (Please post it here on lemmy if you do)

  • perchance@lemmy.worldOPM
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    7 months ago

    Looking forward to seeing the contraptions that you and others build with this.

    btw, I’ve just added c.comments which you can use at any time to get the current comments. Was already possible, of course, but I figured this is easier than keeping track of the list manually with onLoad and onComment. One thing to note is that you should wait until onLoad fires before you use c.comments - since it will always immediately return the comments that are currently loaded. So if the comments haven’t loaded yet, then you’ll get an empty array.

    • BluePower@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      6 months ago

      I’ve got a question: When there’s a lot of comments that even the comments plugin can’t capable of loading all of them even when the load more button is pressed over, do the comments also get affected on that kind of overload? Also, @VioneT@lemmy.world @Alllo@lemmy.world if you’re able to test this it’d be very appreciated!

      • perchance@lemmy.worldOPM
        link
        fedilink
        English
        arrow-up
        2
        ·
        6 months ago

        If the user has stayed on the page, then they can load millions of comments. Basically every comment ever submitted to the comments plugin could be handled by a pretty average mobile phone or computer, since they all have at least a few GB of ram these days – so an absurdly high number. But if they just landed on the page, then they’ll only be able to get the most recent 2000 comments in the chat history. And then from there the comments array will start filling up as new comments come in, with practically no limit to the size.

        Hopefully that answered your question - let me know if it didn’t, or if there are certain use cases that you think would be fun/useful where the current constraints (e.g. 2000 history limit when first landing on page) are not idea.

        • BluePower@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          6 months ago

          I think up to 2000 comments on first visit is fine for me, I’ll be using the comments feature along with the programmatical submitting one to do parsing the contents so that each of them has a unique property, as well as doing a lot more stuff with it. Unless if it only loads comments that are initially displayed on the comments plugin (or only a few hundred on first visit), that would be a problem for me. 😁

          And then from there the comments array will start filling up as new comments come in, with practically no limit to the size.

          That is really important to me because of those behavior I described earlier.

          I just went back from a meeting and somehow saw this posted seconds ago when opening the community tab. Thank you for the answer! I haven’t had an opportunity to try these features yet, I am still working on other more important generator updates stuff.