-
Notifications
You must be signed in to change notification settings - Fork 939
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
tickets: Make ticket closing prompt more granular #1808
base: dev
Are you sure you want to change the base?
Conversation
It has been highlighted by one uses, that the lack of granularity from the closing message, concerns them. Consequently, this commit updates the ticket closing function, to use a variable for the closing message, as opposed to the const. msg. used currently. This acts largely as a prelude to the subsequent commits, which will add more to the message, conditionally, based on the logs YAGPDB will create.
This commit adds the initial condition for updating the closing message, if logs will be created. For both conditions, we want to add a prompt that closing the ticket may take a while, if logs are being created. So this change, creates a builder from the initial message, and adds this reminder, if logs would be created.
Ok, presumably that constant was used elsewhere... will submit a fix promptly... |
Gonna convert this to a draft, because the interactions with slash commands may make it more complicated. |
Due to the design of the ticket button handling functions, closing tickets resulted in the ticket closing prompt being doubled up on with an ephemeral response. For this reason, these prompts served little purpose, as a prompt was already created as a normal message, as part of the `tickets.closeTicket` function. Consquently, this effectively just introduced a dependency on the `tickets.closingTicketMsg` constant, that this series of commits, served to remove.
With commit 333d879, would you please test this with the |
// We only need to build up a more detailed closing msg. | ||
// if we're creating logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We only need to build up a more detailed closing msg. | |
// if we're creating logs. | |
// We only need to generate a more detailed closing message if we're creating logs. |
the full stop is misplaced as is
if conf.TicketsUseTXTTranscripts { | ||
closingMsgBuilder.WriteString("\nCreating logs.") | ||
} | ||
|
||
if conf.DownloadAttachments { | ||
closingMsgBuilder.WriteString("\nDownloading attachments.") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax of the generated message is a bit awkward:
Closing ticket.
Creating logs.
Downloading attachments.
This may take a while if the ticket is long.
I wonder if we can arrange for the message to be more similar to the original. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt the "and so on" read weirdly, as those are the only two actions it's doing, and the comma version reads weirdly without it.
I could have tried to do a version conditionally inserting "and", but this seemed like the least complex approach...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. For completeness, an alternative that is not too complicated is a switch enumerating all the cases, which is not too difficult here:
transcripts, attachments := conf.TicketsUseTXTTranscripts, conf.DownloadAttachments
var closingMsg string
switch {
case transcripts && attachments:
closingMsg = "Closing ticket, creating logs, and downloading attachments. [...]"
case transcripts:
...
...
}
but it is arguable whether this is a real improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the standpoint of minimising allocations, it's almost certainly an improvement. I was thinking of making a change of growing the allocation before building the string, but choosing a single option is almost certainly better,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely more performant, but this code is not on the hot path and we do not make much effort to minimize allocations in general so that concern may be misplaced. The main questions, I think, are quality of the output message, code readability, and extensibility, and it's a bit less clear whether the above suggestion is a meaningful improvement on all three fronts to be worthwhile--I don't have a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively: The initial line could be added as three statements;
Closing ticket. Creating logs. Downloading attachments.
Having looked at my solution, using a switch
statement, and string builder, it doesn't look better to me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a slice of actions joined by commas and switched to title case
at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly see how that helps. It would create a single source for changing any separators, yes, but would largely result in checking the same conditions anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just joins it all into one sentence instead of three separate ones.
maybe I’m not understanding what the current issue is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial quibble, was about the fact I changed the response to be separated onto different lines, and the message reading somewhat strangely as a result. I kind of agree with that in hindsight, and I think the three statements could be on the same line.
So basically, just swapping \n
for
Co-authored-by: Joseph Liu <[email protected]>
333d879 will need to be reverted to maintain current functionality. |
I don't think I will revert that directly, as it still has the issue of depending on the existing constant. An edited version with a more generic response should be reasonable though... |
What do you think about taking the builder you have currently and |
That would result in the work being done up to twice, including when it's not necessary.
|
I’m not saying don’t construct it conditionally, I’m saying put those |
The issue is, that message is only needed in the condition the ticket can be successfully closed. |
it is still possible for that ticket to fail to close after sending that |
It’s arguably significantly more likely that the ticket will fail to create |
Ok. Regardless, it doesn't make sense to construct it before testing those conditions, then again if those conditions do succeed. It makes more sense to do it in |
The “conditions” you’re referring to are just <ticket is already being I still maintain that in most instances people are going to be seeing |
We should outline the potential approaches here, from the user and technical perspective:
|
Edit: crossed out issues addressed by Willow’s edits |
Confusion might be overstating the response to the message being doubled up, but they may question, "Why did the bot post that message twice...??" If YAGPDB was already attempting to close the ticket though, a message stating YAGPDB is attempting to close the ticket, then another saying it's already closing the ticket, almost certainly would be. Alternatively, a generic response of, "Attempting to close ticket." makes a lot more sense followed up with, "Already working on closing this ticket, please wait..." |
I think there is a difference between questioning something and |
I think using |
Imo, given the choice between having a user question something, |
I think something this PR has highlighted, is that there's too much functionality wrapped up in |
A server manager recently expressed their concerns, with YAGPDB
unconditionally suggesting it was downloading attachments
sent in tickets. They left this disabled for the privacy of members,
and felt the prompt may scare members, as it contradicted
their stated behaviour.
This PR updates the ticket closing function,
to use a more granular prompt, based on whether
it is creating a transcript of the ticket and/or downloading attachments.