Skip to content

Commit

Permalink
peaceful registration mode disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
demidko committed Sep 22, 2024
1 parent f6613e4 commit e8ebf34
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
20 changes: 0 additions & 20 deletions src/main/kotlin/com/github/demidko/glock/ChatOps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,6 @@ class ChatOps(
reply(m, rules, Temp(dialogLifetime))
}

fun tryLeaveGame(m: Message) {
if (isRestricted(m)) {
return
}
val dialogLifetime = ofSeconds(10)
markAsTemp(m, dialogLifetime)
if (isIsHePeacefulToday(m)) {
reply(m, "🕊️")
return leaveGame(m)
}
val notification =
"Since you have already shot other users, you cannot quit the game until 24 hours have passed 😈"
reply(m, notification, Temp(dialogLifetime))
}

private fun leaveGame(m: Message) {
val userId = m.from?.id ?: return
userToLastActivity.remove(userId)
}

private fun isIsHePeacefulToday(message: Message): Boolean {
val userId = message.from?.id ?: return true
val lastActivity = userToLastActivity.get<Long>(userId) ?: return true
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/com/github/demidko/glock/GlockBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class GlockBot(
command("buckshot", handleCommand(ChatOps::buckshot))
command("statuette", handleCommand(ChatOps::statuette))
command("heal", handleCommand(ChatOps::heal))
command("leave", handleCommand(ChatOps::tryLeaveGame))
command("help", handleCommand(ChatOps::help))
command("start", handleCommand(ChatOps::help))
message(handleMessage(ChatOps::filterMessage))
Expand Down

0 comments on commit e8ebf34

Please sign in to comment.