1
1
submitted 11 months ago* (last edited 11 months ago) by [email protected] to c/[email protected]

Lemmy Bot Best (Coding) Practices

Because of the increasing amount of Bots on lemmy and there is not (yet) a written Best (Coding) Practices post i want to make such Guideline.

The bot is required to follow the instances rules.

Guidelines

General Guidelines

1. Bots should stagger their calls to different endpoints to reduce the strain on the serverFor example, instead of calling all three endpoints (Posts, Comments, and Reports) every 30 seconds, you could call Posts every 30 seconds, Comments every 35 seconds, and Reports every 45 seconds. This would spread out the load on the server and prevent it from becoming overloaded.

2. Bots should only fetch data that they really need.For example, a spell-checking bot does not need to fetch reports. This will help to reduce the amount of data that your bot needs to store, which will improve performance.

3. Bots should use a cache to store data that is required more often than 30 seconds.This will improve performance and the strain to the server by reducing the number of times that your bot needs to fetch the data from the server.

4. Bots should remove unused data from their database on a regular basis.This will free up space and improve performance.

5. Bots should be crash-safe, meaning that they should be able to recover from unexpected errors.This can be done by using error handling techniques and by storing important data in a way that can be easily recovered and use a Backoff system to increase the retry time until it reaches a limit to stop completly.

6. Bots should add a delay to API-heavy commands and actions.This will help to prevent the server from becoming overloaded.

7. Bots should not connect to multiple instances at a time.This can cause conflicts and errors.

8. Bots should secure their servers.This includes using strong passwords and keeping their software up to date.

9. If you are unsure if your bot is working properly, you should contact your local instanceadmin. They can help you to troubleshoot any problems.
10. Bots should ignore other bots for commands or DMs.This helps to prevent loops.
11. Bots should only fetch the communities that they should interact with.This helps to reduce load on the server.
12. Global bots should be opt-in or have an opt-out feature.This gives users control over whether or not they want to interact with your bot.
13. Bots should have the Bot flag activated AND include the word "bot" or other bot-related words in their name.This helps users to identify your bot and understand its purpose.

For Improvment ideas leave a comment!

Lemmy Bot Support

0 readers
1 users here now

Lemmy Bot Support

Here you can get help and share tips for developing Bots

Resources

Docs

Lemmy API Libraries

Tags

[Meta] - For meta posts about this community

[Showcase] - For Showcasing of a bot / library

[Help] - For asking for help

Partners

Hedges Development

A community of developers and users who are interested in development, privacy and security.

Lemmy JS API

A community focused on developing with the javascript library of the Lemmy API

How to become mod

To become a mod, you need to be active in the community and help people out. If you are active and helpful, you will be invited to become a mod.

founded 11 months ago
MODERATORS