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

  • BluePower
    link
    fedilink
    English
    27 months ago

    Feature request: How can I determine whether a comment is made “programatically” with some variable like comment.isBot or something?

    • @perchanceOPM
      link
      English
      26 months ago

      Thanks! Good feature request. I’ve just added comment.autoSent, and it’s true if it was programmatically submitted. Let me know if there are any issues.

    • BluePower
      link
      fedilink
      English
      16 months ago

      @[email protected] Another one: What if you could just set the nickname for yourself only by using a single function, and not with the com.submit() method?

      • @perchanceOPM
        link
        English
        26 months ago

        Yep, you can do that with: com.setNicknameForNextComment("blah") and their next comment will have “blah” as the nickname. I added this a few days ago but didn’t announce it

        • VioneTM
          link
          English
          16 months ago

          Also the message bubble buttons seems messed up 😅 after the addition of the reply button.

          • @perchanceOPM
            link
            English
            26 months ago

            Can you share screenshot? Not sure what you mean by message bubble buttons

            • VioneTM
              link
              English
              16 months ago

              From /generators page

              From /hub page with Admin enabled.

              • @perchanceOPM
                link
                English
                2
                edit-2
                6 months ago

                Ohh, specifically the admin “delete” button, you mean? If so, thanks! Fixed. I’ve just placed it properly between the reply and block buttons.

                • VioneTM
                  link
                  English
                  1
                  edit-2
                  6 months ago

                  Also there seems to be the ‘delete’ comment on replies (not sure if intended but clicking on it works to delete the reply and the mentioned comment):

                  • @perchanceOPM
                    link
                    English
                    26 months ago

                    Thanks! 🙏 Should be fixed now.