Adding a command - BIRD-UP73/nsfw-bot GitHub Wiki
When adding a command there are a few steps you need to go through.
Go to url/urls.py and add the URL there
Each URL enum entry contains
- The short URL, used a as a key and in the database to store favorites
- The long URL, used to make API calls (will default to
https://<short_url>/index.php) - The cheatsheet URL, to link the user to search terms used on the image board
- Create a class that extends
NsfwCommandincommands/nsfwand fill in the required attributes Thenamerequired. - The URL is needed if the command actually needs to fetch posts from an API
- In
commands/nsfw/_setup.py, add the command
The default post fetching behavior is defined in posts/json_post_fetcher.py and posts/xml_post_fetcher.py.
If your command needs to fetch posts in a different way, you should create a custom class that extends PostFetcher in posts/fetcher.
This fetcher should then be added in the ``
Sometimes the site API has a weird way of handling pages (does it start from 0, is it < post_count or <= post_count)?
For this you can create a custom class that extends Paginator in posts/paginator.
The custom fetcher and/or paginator should be defined in a separate method in the class PostMessageFactory in posts/post_message/factory