bird-up73 / nsfw-bot Goto Github PK
View Code? Open in Web Editor NEWA Discord bot that posts NSFW images
A Discord bot that posts NSFW images
When a favorite is removed, the embed resets back to page 0.
The page number should only reset if the user deletes the last favorite.
Add more sites such as
Does not fetch counts, so using a random page will be impossible
Test issue for discord
The class PostMessage
has several methods that can also be used by the PageEmbedMessage
, and therefore also by AbstractPost
.
These are
fetch_total_posts()
fetch_post_for_page()
When scrolling through posts in the favorites
and history
command, a post is fetched for every time a user scrolls through the pages.
This result should maybe be cached. So that posts are not re-fetched every time.
When storing posts in the history it should be possible to store the whole post?
Use a custom help command for this?
Also generify emoji explanations
Since r34 uses gelbooru, check if tags can be used
The on_reaction_add functions are kind of a mess right now?
Is there any way to simplify them, while also using inheritance?
One idea is to use a dictionary with emojis
emojis = {
'⬅': handle_next_page(),
'➡': handle_previous_page()
}
For the class handling reactions, the on_reaction_add(reaction, user)
should get the emoji, and then
Tangential:
ctx
from classes?Files are in folders that dont really explain what they are for
Since each command requires quite a lot of options, it might be better to create separate classes for them instead of in 1 cog.
Using the observer pattern might decouple some more dependencies
There is still a lot of code duplication.
I wanna find a way to reduce this.
Some more ideas:
Use discord-py-slash-command in a separate branch and see how it works.
The pages used in the API might start with 0.
This might need to be corrected for when displaying pages
Add logging for the following cases
Right now it is only possible to see random posts by reacting with 🔁.
Maybe it should be possible to browse through posts in order.
This should include two reactions for generic post commands.
⬅ and ➡ to cycle through pages
Danbooru does not keep track of page numbers in posts.
This makes it impossible to fetch a random post. Which page are you even on?
If a user stores a favorite, the time at which they did so should be stored.
This should be added as a column in the database.
When fetching the favorites, these should be sorted by this datetime.
This makes sure that the class PostHistEntry
can be removed, since it would be identical to PostEntry
When a user asks for favorites, the embed timestamp should show when the favorite was saved in the timstamp.
Right now posts are probably not deleted.
There should be a cog to manage posts and delete them if a message is deleted.
There are three events that would be nice to handle.
This is largely the same for History and Favorites
However, idk how to make this generic
There is more inheritance than composition right now, this should be changed.
It might be useful to define responsibilities per class to give these the appropriate methods.
How to handle the FavoritesMessage
behavior though? How to delete favorites and handle reactions?
The post history is stored globally. This history should be stored per guild and/or DM.
When adding a favorite from the post history, an error is thrown
If the favorites or history contain a deleted post, this should be shown in the embed.
It should also not be possible to store a deleted post as favorite.
Make sure all URLs are used in one place.
Especially the URL for danbooru.
Find a way to store favorites.
Have a possibility to display HTTP errors that occur when fetching a post?
Sites like rule34 and gelbooru only give tags, but not the artist.
Is there any way to find out what the artist is?
When refreshing a post, there should be some kind of embed showing an error if the post contains a disallowed tag.
It should still be possible to refresh again or delete.
The Post
class should have an abstract method is_allowed()
.
The PostData
should have an extension class that displays an error.
An abstract class AbstractPostData
or something should be added.
Use the URL
class instead of a str
for a URL
For xml-based APIs the total amount of posts is fetched for every request that is made.
This should only be done once since it will probably increase performance.
One disadvantage is that the total amount of posts can change while you browse.
However this probably does not have a lot of impact, since you only don't see posts that were created after u requested them.
Instead of fetching post information in XML format, check if it is possible to use JSON.
It will be easier to parse and u only need one parser.
TODO:
Add the embed title to the PostMessage class, this reduces the need to set it for every class
A lot of different classes use logic to create a dict
with message content:
dict(content=..., embed=...)
and will create embeds depending on whether content is set.
It would probably be better to create a class that handles this.
The bot has lots of different commands, maybe it is good to put them in separate groups.
This will make the help command shorter, and might make it easier to see which command goes where.
A possible disadvantage of using groups is that I don't know if u can invoke commands on their own if they are in a group.
This is something I need to figure out.
:PiplupSad:
Create a factory class to create posts
It might be better to store posts by ID instead of several attributes used now.
This makes it possible to scroll through favorites and post history easier.
It also makes it possible to store both animated and static posts.
When attempting to remove a user's reaction on a message in a DM channel, the following error is returned
50013 - You lack permissions to perform that action
See also https://discord.com/developers/docs/topics/opcodes-and-status-codes#json
Provide some explanation about what the emojis do.
Where to do this? Put this in help mapping?
Or put it in every help command
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.