Images, when saved in discord, naturally expire after sometime, and deleting the "hosting" message makes the image itself disappear, this issue gets compounded with quotes over time, meaning that the older a message is, the more likely it is that a quoted image no longer exists.
It is CRUCIAL that a solution to that problem DOES NOT need any new supporting infrastructure.
One possible solution (For images hosted in discord):
User uploads a link to some sort of media hosted in Discord (Ending in .png,.jpg and other extensions specified in f43520e51d/settings/config.py (L62) )
The bot downloads the image in an specified directory by using requests and writing directly to a file:
When the quote is called, the bot uploads the file:
#The quote will be saved in the database as "#FILE=/mnt/downloadedquotes/<id>.png", for exampleifcontent[:6]=="#FILE=":filedir=content[6:]withopen(filedir,'rb')asf:picture=discord.File(f)returnawaitbot.send(file=picture)
Naturally, we expect all quotes to be saved in the same table.
This solution will, naturally need to be replicated in all "quote-responding" references:
Maybe it is also time to make this a single function :þ
Images, when saved in discord, naturally expire after sometime, and deleting the "hosting" message makes the image itself disappear, this issue gets compounded with quotes over time, meaning that the older a message is, the more likely it is that a quoted image no longer exists.
It is **CRUCIAL** that a solution to that problem **DOES NOT** need any new supporting infrastructure.
One possible solution (For images hosted in discord):
1. User uploads a link to some sort of media hosted in Discord (Ending in `.png`,`.jpg` and other extensions specified in https://brejela.club/gitea/neeble-club/neeble/src/commit/f43520e51db9db145813e4d6f294ac21a67b9d65/settings/config.py#L62 )
2. The bot downloads the image in an specified directory by using `requests` and writing directly to a file:
```py
import requests
url = 'https://media.discordapp.net/attachments/1007369896822317178/1189268533285236808/image.png'
file = requests.get(url)
filedir = str(os.environ.get('DOWNLOADED_QUOTES', '/mnt/downloadedquotes/') + '<quote id>.png'
open(filedir, 'wb').write(myfile.content)
```
3. When the quote is called, the bot uploads the file:
```py
#The quote will be saved in the database as "#FILE=/mnt/downloadedquotes/<id>.png", for example
if content[:6] == "#FILE=":
filedir = content[6:]
with open(filedir, 'rb') as f:
picture = discord.File(f)
return await bot.send(file=picture)
```
Naturally, we expect all quotes to be saved in the same table.
This solution will, naturally need to be replicated in all "quote-responding" references:
https://brejela.club/gitea/neeble-club/neeble/src/commit/f43520e51db9db145813e4d6f294ac21a67b9d65/utils/commands.py#L185
https://brejela.club/gitea/neeble-club/neeble/src/commit/f43520e51db9db145813e4d6f294ac21a67b9d65/utils/commands.py#L215
https://brejela.club/gitea/neeble-club/neeble/src/commit/f43520e51db9db145813e4d6f294ac21a67b9d65/utils/commands.py#L249
Maybe it is also time to make this a single function :þ
brejela
added this to the General media-quoting improvements project 2 years ago
Images, when saved in discord, naturally expire after sometime, and deleting the "hosting" message makes the image itself disappear, this issue gets compounded with quotes over time, meaning that the older a message is, the more likely it is that a quoted image no longer exists.
It is CRUCIAL that a solution to that problem DOES NOT need any new supporting infrastructure.
One possible solution (For images hosted in discord):
.png
,.jpg
and other extensions specified inf43520e51d/settings/config.py (L62)
)requests
and writing directly to a file:Naturally, we expect all quotes to be saved in the same table.
This solution will, naturally need to be replicated in all "quote-responding" references:
f43520e51d/utils/commands.py (L185)
f43520e51d/utils/commands.py (L215)
f43520e51d/utils/commands.py (L249)
Maybe it is also time to make this a single function :þ