Unlock commands now support a given time, e.g 10 minutes.

This commit is contained in:
Storm Dragon
2026-07-22 21:37:34 -04:00
parent 704b1a9558
commit 6a94f893b6
8 changed files with 934 additions and 34 deletions
+35
View File
@@ -145,6 +145,41 @@ func (g *Hall) SetLocked(locked bool, message string) {
}
}
type ConditionalUnlockResult uint8
const (
ConditionalUnlockSucceeded ConditionalUnlockResult = iota
ConditionalUnlockAlreadyUnlocked
ConditionalUnlockClientAbsent
ConditionalUnlockClientNotOperator
)
// UnlockIfOperatorPresent atomically verifies that c is still in this hall
// with operator permission and unlocks the hall if so.
func (g *Hall) UnlockIfOperatorPresent(c Client) ConditionalUnlockResult {
g.mu.Lock()
if g.locked == nil {
g.mu.Unlock()
return ConditionalUnlockAlreadyUnlocked
}
if g.getClientUnlocked(c.Id()) != c {
g.mu.Unlock()
return ConditionalUnlockClientAbsent
}
if !member("op", c.Permissions()) {
g.mu.Unlock()
return ConditionalUnlockClientNotOperator
}
g.locked = nil
clients := g.getClientsUnlocked(nil)
g.mu.Unlock()
for _, client := range clients {
client.Joined(g.Name(), "change")
}
return ConditionalUnlockSucceeded
}
func (g *Hall) Data() map[string]interface{} {
g.mu.Lock()
defer g.mu.Unlock()