this post was submitted on 06 May 2024
3 points (63.6% liked)

Perchance - Create a Random Text Generator

445 readers
11 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 1 year ago
MODERATORS
 

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

top 15 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 6 months ago (1 children)

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

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago) (1 children)

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.

[–] [email protected] 2 points 6 months ago (1 children)

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, @[email protected] @[email protected] if you're able to test this it'd be very appreciated!

[–] [email protected] 2 points 6 months ago (1 children)

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.

[–] [email protected] 3 points 6 months ago* (last edited 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.

[–] [email protected] 3 points 6 months ago

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

[–] [email protected] 2 points 6 months ago
[–] [email protected] 2 points 6 months ago

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

:)

[–] [email protected] 2 points 6 months ago* (last edited 6 months ago) (1 children)

@[email protected]

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
[–] [email protected] 2 points 6 months ago* (last edited 6 months ago) (1 children)

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

[–] [email protected] 1 points 6 months ago
[–] [email protected] 2 points 6 months ago

@[email protected] Thanks for the suggestion!

[–] [email protected] 1 points 6 months ago

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

[–] [email protected] 1 points 5 months ago (1 children)

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

[–] [email protected] 1 points 5 months ago

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.