Jintaku / Jintaku-Cogs-V3

V3 Cogs made by the Jintaku community
GNU Affero General Public License v3.0
39 stars 40 forks source link

Test gifs at startup #58

Open Sandvich opened 3 years ago

Sandvich commented 3 years ago

So to deal with the issue of dead links, it would be good to have some kind of automatic test that checks for and removes dead links at startup/cog loading. But I'm not that good at the async stuff, so I could use some help with this.

My current thought is that, in the __init__ function for roleplay, we could have something like this at the end:

for command in default_global.keys():
    new_gif_list = []
    for gif in default_global[command]:
        code = requests.get(gif).status_code
        if code < 400:
            new_gif_list.append(gif)
    default_global[command] = new_gif_list
self.config.register_global(**default_global)

Of course, I'd like to remove the dependency on requests and also make this asynchronous, but as I say, I'm not that great with async. I'd appreciate any help!