(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)

  • VioneTM
    link
    English
    17 months ago

    See this silly video

    Since you have a ‘mirror’ on the bottom one, the com.inputText is being applied on the last instance of the comments. Which is why it isn’t being mirrored on the top one.

    • BluePower
      link
      fedilink
      English
      1
      edit-2
      7 months ago

      Oh, I tried that, and it actually did, I definitely didn’t see that before. 😆 But I only assign the com variable to the first instance of the commentsPlugin(), so this could be kind of a strange bug. @[email protected]

      Also a feature request, would there be a special event when the user clicks on the submit button? It’s like onComment() except it works only for the person who submits their own comment.

      • VioneTM
        link
        English
        17 months ago

        You can check if the current user has submitted with comment.byCurrentUser