Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Mods are watching #110

Open
tigattack opened this issue Jan 22, 2021 · 18 comments
Open

[FEAT] Mods are watching #110

tigattack opened this issue Jan 22, 2021 · 18 comments
Assignees
Labels
new-cog New cog for bot.

Comments

@tigattack
Copy link
Member

tigattack commented Jan 22, 2021

Overview

Mods are watching functionality, à la Araquiel's :eye: trigger.
Example:
image

Cog should build these images on the fly to avoid issues with hardcoding. Suggest using imgflip API or similar. If using imgflip, use template ID 224894675.

I'm not sure if this is best as an extension of the autoreply cog or a cog of its own. Due to this, I've not filled out the suggested commands below.

Commands

[p]modmeme <enable|disable> <watching|frog|horse>
[p]modmeme trigger <watching|frog|horse> :emote: # Trigger conflicts should not be allowed.
[p]modmeme setname <@modUser> <name> # Default to current user if user param not specified.
[p]modmeme setnamelimit <int> # Default to 32 chars if not specified.

DoD

  • A member of the moderation team can post 👁️ (:eye:) and the bot responds as demonstrated above.

Stretch

  • Frog image, again replicating Araquiel's functionality. The implementation of this was not-so-ideal on the back end though. Suggest this is triggered by a mod posting 🐸 (:frog:) or similar. Open to suggestions here!
    image
@tigattack tigattack added the new-cog New cog for bot. label Jan 22, 2021
@reichbc
Copy link

reichbc commented Feb 2, 2021

I suggest adding Horse of Disapproval for extra emphasis on the disapproval...
horse-of-disapproval

@tigattack
Copy link
Member Author

If you can produce the same end result with the imgur API, then that's fine 👍 I've created a mirror of the template here if that's any help.

The only thing I notice is that while it is official, the imgurpython project has been deprecated since late 2017, so it may be better to find an alternative if possible.

I'd welcome input from @issy or any other member of the team who has any suggestions regarding this.

@jeevanshah07
Copy link

jeevanshah07 commented May 27, 2021

Ok thanks. I realized that it's probably easier to use the imgflip api to create custom memes (ie. (Mod name) is watching) so that's what I'll prob use.

@tigattack
Copy link
Member Author

OK. You can use imgflip template ID 224894675.

@issy
Copy link
Member

issy commented May 27, 2021

The purpose of the imgflip API in this cog is for image editing, not image storing - therefore the imgur API does not provide the same featureset that we need.
One note I will pass on is that I had a lot of trouble adding a second custom text field to an image with the API. It is not entirely clear from the API docs how they want you to format the array. I am sure you will see what I mean when you look into it.
Recently I've been thinking about the possibility of using a library such as PIL to do this, meaning we don't rely on a third party API

@tigattack
Copy link
Member Author

Since the template's upper text box is in the correct position there's no need to specify anything more than the text, so this is very easy:

>>> import requests
>>> body = {'username':'redacted','password':'redacted','template_id':'224894675','font':'arial','boxes[0][text]':'your mum'}
>>> req = requests.post('https://api.imgflip.com/caption_image',data = body)
>>> print(req.text)
{"success":true,"data":{"url":"https:\/\/i.imgflip.com\/5b5vyr.jpg","page_url":"https:\/\/imgflip.com\/i\/5b5vyr"}}

Resulting image.

I'm sure there's a better way to do it, but this works fine as a PoC.

@issy
Copy link
Member

issy commented May 27, 2021

Thanks for the snippet, Tig. That's definitely different from what I was doing :D
IIRC my method wasn't retaining font styling, but that seems to be retaining them perfectly.

@issy
Copy link
Member

issy commented May 27, 2021

Suggested command usage RFC

[p]modmeme <enable|disable> <watching|frog|horse>

@jeevanshah07
Copy link

This all looks really good! The frog and horse won't need any captioning right?

@issy
Copy link
Member

issy commented May 27, 2021

Nope, they won't need any captioning. I've created imgflip templates for both of them, if that makes life easier.
Frog: 321087939
Horse: 321088192

@jeevanshah07
Copy link

jeevanshah07 commented May 27, 2021

Also do you guys want a hardcoded username and password or is there some sorta config file that I can edit? And should the triggers be hardcoded?

@issy
Copy link
Member

issy commented May 27, 2021

Pull the username/password from the API key store built into Red. Documentation here
It works similarly to the config class

@tigattack
Copy link
Member Author

I'd like to suggest another command:

[p]modmeme trigger <watching|frog|horse> :emote: # Trigger conflicts should not be allowed.

Also, a note regarding the enable|disable command: I think it should default to be global enable/disable if the second param is not specified.

@jeevanshah07
Copy link

I'd like to suggest another command:

[p]modmeme trigger <watching|frog|horse> :emote: # Trigger conflicts should not be allowed.

Also, a note regarding the enable|disable command: I think it should default to be global enable/disable if the second param is not specified.

Noted. By trigger conflicts I assume you mean the auto reply triggers?

@issy
Copy link
Member

issy commented May 27, 2021

Yep, so to check that you'll have to get the config object from the autoreply cog. Bear in mind, you have to check that the cog is loaded as well. Something like this would probably be ok
triggers should be allowed between autoreply and modmeme; just not between the different modmemes

@tigattack
Copy link
Member Author

tigattack commented May 27, 2021

Another idea I've just had:

Nicknames would be best to use for the template text since they can differ from the username and members may know a mod by their nickname rather than username.
However, Discord has a limit of 32 characters for nicknames which could make the template unreadable or look poorly formatted.

I suggest that by default it uses the nickname, but has the following options available:

[p]modmeme setname <@modUser> <name> # Default to current user if user param not specified.
[p]modmeme setnamelimit <int> # Default to 32 chars if not specified.

I'm aware I'm causing a lot of scope creep here, sorry about that. Clearly I didn't think this through very thoroughly!
Please consider these suggestions to be stretches rather than DoD's.

@jeevanshah07
Copy link

It's all fine. It will probably be a bit before I can get a working cog as I've never worked with RED before😅

@issy
Copy link
Member

issy commented May 27, 2021

No worries 👍 having this discussion helped us clear up a lot of the implementation details anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cog New cog for bot.
Projects
None yet
Development

No branches or pull requests

4 participants