Conversation
Some of the tests were failing because they were expecting send_webhook to be a method of the DuckPond cog, other tests simply were no longer applicable, and have been removed. #667
This shouldn't be used as a replacement for ModMail, but I think it makes sense to have the feature just in case #dm-log provides an interesting use-case where responding as the bot makes sense. It's a bit of a curiosity, and Ves hates it, but I included it anyway. #667
Also now catches the exception if a user has disabled DMs, and adds a red cross reaction. #667
kosayoda
left a comment
There was a problem hiding this comment.
Sweet!
As it stands, moderators can !reply anywhere in the server. Is that something we want?
Hmm, good question. We might want to contain that in the #dm-log channel so that all the dm traffic (both in and out) is in one place. I'll make that change. |
|
Should the cog make some attempts to mitigate issues when the !reply command is used for the last user, but an another DM comes in while the invokation message is being sent and processed? |
I did consider this, and I wonder how much of a problem it's really going to be. How would you suggest we could go about mitigating this anyway? |
|
the easiest approach would be to just remove the whole last user feature altogether and always require a member to be specified. More technical approach would be some sort of locking mechanism, but I'm not really keen to complicate this. This feature is absolutely not meant to be used for anything serious, so it feels like even if the DM gets delivered to the wrong person, it shouldn't really do any damage. |
|
Perhaps some sort of a delay on the setting the user would be enough to give time for the person writing it to notice the change without influencing other things. |
|
Yeah, I'm leaning towards just simplifying and requiring the user to prevent this kind of race condition issue. We don't have any such stats from what I'm aware. I'm curious myself. Maybe this PR should add stats for that, too. |
If you're typing up a reply and the bot gets another DM while you're typing, you might accidentally send your reply to the wrong person. This could happen even if you're very attentive, because it might be a matter of milliseconds. The complexity to prevent this isn't worth the convenience of the feature, and it's nice to get rid of the caching as well, so I've decided to just make .reply require a user for every reply. #1041
|
oh shit, that last commit was supposed to be two commits, but anyway I've made the changes requested by @kosayoda and @Numerlor now:
|
Without this, it is difficult to know precisely who the user that is DMing us is, which might be useful to us. #1041
When we're using the !reply command, using a regular UserConverter is somewhat problematic. For example, if I wanted to send the message "lemon loves you", then I'd try to write `!reply lemon loves you` - however, the optional User converter would then try to convert `lemon` into a User, which it would successfully do since there's like 60 lemons on our server. As a result, the message "loves you" would be sent to a user called lemon.. god knows which one. To solve this bit of ambiguity, I introduce a new converter which only converts user mentions or user IDs into User, not strings that may be intended as part of the message you are sending. #1041
Add upstream changes & resolve config conflicts introduced by #1041. In the conflicting parts of the diff, this commit also re-sorts constants which were added upstream to lexicographical order. This does **not** re-sort all constants added upstream.
This PR adds a feature which will relay DMs sent to the bot through a simple webhook relay system. It also provides a mechanism for responding to these DMs, should you need to do so.
The mechanism for responding will by default respond to the last person who DMd the bot, but can optionally take a member parameter to reply to a specific member.
Refactoring Duck Pond and Python News
To do this in a DRY way, I first refactored the send_webhook helper used in Duck Pond into a generic util, which could be used for both Duck Pond and the DM Relay cog.
As it turns out, we had a similar mechanism in use over in the Python News handler as well, so I had to refactor that as well to use this util.
Fixing the DuckPond tests
Holy shit, DuckPond has ten million tests, and half of them broke when I made the first change. So I had to fix some of those broken tests.
Add the DMRelay cog
Next, we add a cog that will just relay anything that is a DM sent by a human to the right channel. The cog also adds the command to allow you to respond. Easy peasy.
Closes #667.