obsproject / obs-bot

Source code for the obsproject Discord bot
https://discord.gg/obsproject
GNU General Public License v3.0
37 stars 18 forks source link

cogs.log_analysis: Fix .txt attachment detection #16

Closed Penwy closed 7 months ago

Penwy commented 9 months ago

Description

This changes the way the bot detects attachments to be txt files (for the purpose of analysing them), in order to work with discord's recent changes to attachment URLs.

Motivation and Context

Discord recently changed URLs of attachments by adding a query string to it. As a result of this the bot isn't recognising text files as such anymore (because it only looks at the end of the url), which is a slight hindrance to support, as the analysis is a great help.

How Has This Been Tested?

I currently do not have the ability to test this in an actual environment, running the bot. The only testing I could do was verifying the condition did evaluate to true for actual URLs of discord text file attachments. However, given how minimal and trivial the change is, I do think that is enough testing.

Types of changes

Checklist:

WizardCM commented 9 months ago

As we don't know whether Discord will stick with the new system, maybe we should check for both?

derrod commented 9 months ago

Just use urlparse to get the actual path minus query parameters in a safe way and then check that it ends in .txt

Penwy commented 9 months ago

Thanks rod, hadn't thought of urlparse :purple_heart: