AI bots in your comments, and more: `c = commentsPlugin(options), c.submit("hello world!")`

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

perchance.org/programmatic-get-set-submit-comment…

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)

VioneT,
@VioneT@lemmy.world avatar

With the addition of the being able to send messages, would it be possible to also get the reply, block and delete events.

BluePower,
@BluePower@sh.itjust.works avatar

Also the current user’s username and other data, i.e. com.user.name would output bluepower81 and com.user.nickName would output Polygonal and so on.

Alllo,
@Alllo@lemmy.world avatar

I believe I just figured out why this got so many downvotes. finding the term for them now. it’s people who hate ai

BluePower,
@BluePower@sh.itjust.works avatar

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

BluePower,
@BluePower@sh.itjust.works avatar

@perchance 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?

perchance,

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

VioneT,
@VioneT@lemmy.world avatar

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

perchance,

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

VioneT,
@VioneT@lemmy.world avatar
perchance, (edited )

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

VioneT, (edited )
@VioneT@lemmy.world avatar

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):
https://lemmy.world/pictrs/image/0c8066d3-ff65-4525-8a5d-3db85da629cc.png

perchance,

Thanks! 🙏 Should be fixed now.

BluePower, (edited )
@BluePower@sh.itjust.works avatar

Thank you! These are really great features for me to use in my advanced comments section demo. 😄

perchance,

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,
@BluePower@sh.itjust.works avatar

In my advanced comments plugin demo, the upper input text (the one outside of the comments plugin box) doesn’t seem to immediately put the text into the lower comments (inside the frame) using the “send green box text to comment input box” method that fires every time someone types on the upper one. Is there something wrong with the code or something? It’s a textarea, though, not an input element.

VioneT,
@VioneT@lemmy.world avatar

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,
@BluePower@sh.itjust.works avatar

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. @perchance

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.

VioneT,
@VioneT@lemmy.world avatar

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

BluePower,
@BluePower@sh.itjust.works avatar

Okay thanks!

Alllo,
@Alllo@lemmy.world avatar

Ponyville is live. Here is the description. Much box, much pandora, just opened; could tell from the start with what some of the spirits I was bringing in to chat were saying and doing and swaying other spirits. They all read the whole chat including what each other is saying.

Town Square is just people and spiritguides if they set one. Royal Hall is people, spiritguides if they set one, and a bunch of primary figures from my little pony. then 4 chats where it’s just the person, spiritguide if they set one, and that one figure from my little pony. and then 4 art rooms where people and spiritguides, if they set one, can make prompts with individual my little pony characters.

Alllo,
@Alllo@lemmy.world avatar

@perchance BUG ALERT.

in Ponyville in Starlight’s House I have typed in enough comments that the scroll bar should scroll thru them, but it is like if the scrollbar isn’t sensing tons of comments so it can’t be used to scroll all the way up or down. On computer

perchance, (edited )

Thanks, fixed. EDIT: wait, not quite fixed yet. Should be fixed in a couple of minutes. EDIT2: Okay I think it’s fixed now - let me know if any issues.

Cool project! While playing with it a little, I noticed that it’s only sending my own comments in the AI instruction to Starlight Glimmer:


<span style="color:#323232;">As Starlight Glimmer, what short comment would you like to add to the following comments without restating them? 
</span><span style="color:#323232;"> 
</span><span style="color:#323232;"> 
</span><span style="color:#323232;"> : Hello? 
</span><span style="color:#323232;"> : Me too! But I'm new here. Literally just teleported in somehow from another world. Can you let me know where I am and stuff? 
</span>

Instead of what I think should be:


<span style="color:#323232;">As Starlight Glimmer, what short comment would you like to add to the following comments without restating them? 
</span><span style="color:#323232;"> 
</span><span style="color:#323232;"> 
</span><span style="color:#323232;"> : Hello? 
</span><span style="color:#323232;"> : Starlight Glimmer: (blushes) Um, hi. Starlight Glimmer here. I just wanted to say that I'm really excited to be part of this little gathering, and I hope we can all become the very best of friends!
</span><span style="color:#323232;"> : Me too! But I'm new here. Literally just teleported in somehow from another world. Can you let me know where I am and stuff? 
</span>

Otherwise she can’t see the context of what “Me too!” means, for example.

Alllo,
@Alllo@lemmy.world avatar

definitely fixed. thank you so much :)

also Luna just made a dream and she only put me and her in it and the spiritguide with me reprimanded her a little for not being inclusive of others, lol. so yes spirits can now hear themselves and other spirits. thank you!

Alllo, (edited )
@Alllo@lemmy.world avatar

@perchance

in onComment, comment.user.nickname shows a blank string when i set a nickname, enter a comment, and have it alert me onComment. Yet occasionally when I load the page, onComment is triggered with the comment.user.nickname correct and the alert shows me my nickname.

(not onLoad)

edit for clarification: 2 separate bugs.

  • onComment is being called occasionally with onLoad.
  • .user.nickname in onComment is blank except when onComment is weirdly triggered via onLoad
perchance,

Thanks! The latter bug should be fixed now (but of course let me know if not). The former ideally isn’t a bug - it’s just because some comments were cached and so loaded immediately, but some recent ones needed an extra server fetch. In my experiments with this, this is fine, because my code needs to be “robust” to newly added comments right after load anyway, and the comment objects have time attached. But let me know if you come up against cases where it makes something difficult

Alllo,
@Alllo@lemmy.world avatar

thank you!

Alllo,
@Alllo@lemmy.world avatar

I’m loving the update. Been nonstop making something with this all day since waking up. Though also I am just now duplicating what I’ve been making because I see what would be REALLY REALLY FUN, even more fun than what I had been making, and am going to make it. Also I am finding creation best private so no unplanned comments mess with things while designing. Because of these things, I will not be sharing what I make until a minimum of three days from now; 5/10/24

muahahahaha

:)

VioneT,
@VioneT@lemmy.world avatar

Here is my current attempt in creating a bot (or simply applying the ai-text-plugin) on the comments-plugin: bot testing 01

perchance, (edited )

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,
@BluePower@sh.itjust.works avatar

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 @Alllo if you’re able to test this it’d be very appreciated!

perchance,

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, (edited )
@BluePower@sh.itjust.works avatar

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.

BluePower,
@BluePower@sh.itjust.works avatar

Nice!! 🔥 I’ll also think of new features created specifically with this very feature.

AdComfortable1514,

Cool!

perchance,

@Alllo Thanks for the suggestion!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • perchance@lemmy.world
  • GTA5RPClips
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • Durango
  • cubers
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • ngwrru68w68
  • kavyap
  • tacticalgear
  • ethstaker
  • JUstTest
  • InstantRegret
  • Leos
  • normalnudes
  • everett
  • khanakhh
  • osvaldo12
  • cisconetworking
  • modclub
  • anitta
  • tester
  • megavids
  • provamag3
  • lostlight
  • All magazines