-
-
Notifications
You must be signed in to change notification settings - Fork 89
Auto-free inactive help channels #419
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
Conversation
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/ChannelMonitor.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/Features.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeChannelMonitor.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeChannelMonitor.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeHelpChannelsRoutine.java
Outdated
Show resolved
Hide resolved
u do realise that all of the logic for this has already been written?? (its currently set to an hr but thats easy to change) all u need to do is create a routine, give it a reference to to free channel and call so its litterally like 5 lines of code
thats all thats needed .... obviously not that exact code but u have to add a one liner to a routine class thats it. |
Cool. Nice to see how well you prepared for this feature already. Unfortunate, that we overlooked it 😆 |
@MaiTheLord the purpose of programming is NOT to do each and every tiny thing that needs doing to perform a task as part of that task each and every time u want the task done .... this leads to inconsistency, bugs, unmaintainable code, no chain or responsibility and just about every bad practice that exists for programming! the purpose is to group all actions required for a task in a single place so that u never have to do each tiny thing manually and so that there is only ever one place in the code where that action is controlled and so that the action always happens the same way. since the channel should NEVER be free'd without users getting a message telling them that it is free .... u dont have to do it urself because its already written as part of the code to free a channel |
I never said anything like this. |
it calls other methods and when it does (eventually) change the status of a channel, the method that is called to do so ALSO sends a channel message to notify users thats the point ... the checkStatus method IS NOT RESPONSIBLE for changing the status of a channel, so it SHOULD NOT be responsible to sending a message that states the channel is free tasks get grouped and called in a logical structured manner so that things like sending a message when the status changes does not get forgotten by expecting checkStatus to send messages is the same as saying "my apartment building is so cool its got a doorman to open the doors for visitors. If u want to visit just call 5 mins before so i go down and unlock the door so he can let u in" ..... whats the point of the doorman if ur still doing all of the work urself? |
public synchronized void setFree() {
status = ChannelStatusType.FREE;
} where is the part that sends the message? |
checking .......
oh bleh :( So yeah, more than just 5 lines of code, but not a lot more. That still doesn't change the point that the routine should not be sending messages to tell that the the channel is free. That is outside the scope of its reponsibility (which is to keep track of time and get the free system to update itself at a certain interval) Rewriting all of the code that is basically already found in free command for the routine was not ideal. . if not then u just move the action outside of the slashcommand
The point is keep the message sending all in one place instead of having some in free command, some in routine, and some who knows where else. You will never debug it if the same thing happens in more than one place, only one of them is making a problem and you dont know which one. |
Why can't we just add a .filter(this::isChannelInactive)
.peek(channel -> {
if (shouldSendMessage) {
channel.sendMessage("This channel is now...").queue();
}
})
.map(TextChannel::getIdLong)
.forEach(this::setChannelFree); |
dont use peek, its strictly !!! for debugging it can be short circuited and all sorts of other nasty side effects. u have identified the common method though, well done |
@MaiTheLord Hey, are you still working on this PR? ^^ |
I was busy lately (and still am), so not really. |
I see, thanks for the update. ❤️ You wouldn't mind if someone takes over? |
I wouldn't mind. |
442d883
to
3ea8b5f
Compare
Taken over, rewritten based on the previous general approach by @MaiTheLord . |
Looks good. can't approve as I originally opened the PR |
application/src/main/java/org/togetherjava/tjbot/commands/free/AutoFreeRoutine.java
Outdated
Show resolved
Hide resolved
3ea8b5f
to
dba15c4
Compare
application/src/main/java/org/togetherjava/tjbot/commands/free/FreeChannelMonitor.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
Overview
Implements and closes #392.
Automatically frees all help channels that are inactive for more than 2 hours:
Details
Solved by introducing a
AutoFreeRoutine
which executes each 5 minutes, processing the channels.Functionality that has to be used by both,
FreeCommand
and theAutoFreeRoutine
, has been moved over toFreeChannelMonitor
, which both now take as constructor parameter.Config changes
The config slightly changed, introducing two new args to the
FreeCommandConfig
, looks like this: