code refactor
This commit is contained in:
parent
7275b93666
commit
d157f9b2c9
6 changed files with 187 additions and 193 deletions
|
|
@ -12,6 +12,7 @@ const (
|
|||
AdminApprovedMsg = "✅ Join #request approved for %s [<code>%d</code>]\n\n<b>Join reason</b>: %s\n<b>Approved by</b>: %s\n<b>Approved at</b>: %s"
|
||||
AdminDeclinedMsg = "❌ Join #request declined for %s [<code>%d</code>]\n\n<b>Join reason</b>: %s\n<b>Declined by</b>: %s\n<b>Declined at</b>: %s\n<b>Declined reason</b>: %s"
|
||||
AdminFailedMsg = "⚠️ Join #request failed for %s [<code>%d</code>]\n\n<b>Join reason</b>: %s\n<b>Failure reason</b>: %s"
|
||||
defaultReason = "(no reason provided, reply to this to set one, prepend with + to also send to user)"
|
||||
)
|
||||
|
||||
// Types shared by handler files
|
||||
|
|
@ -32,20 +33,13 @@ type Bot struct {
|
|||
func (bot *Bot) GetPendingUser(userID int64) *ExtendedChatJoinRequest {
|
||||
bot.mu.RLock()
|
||||
defer bot.mu.RUnlock()
|
||||
user := bot.WaitingForApproval[userID]
|
||||
if user == nil {
|
||||
return nil
|
||||
}
|
||||
return user
|
||||
return bot.WaitingForApproval[userID]
|
||||
}
|
||||
|
||||
// SetPendingUser stores a pending user request (write-safe).
|
||||
func (bot *Bot) SetPendingUser(userID int64, user *ExtendedChatJoinRequest) {
|
||||
bot.mu.Lock()
|
||||
defer bot.mu.Unlock()
|
||||
if _, ok := bot.WaitingForApproval[userID]; !ok {
|
||||
bot.WaitingForApproval = make(map[int64]*ExtendedChatJoinRequest)
|
||||
}
|
||||
bot.WaitingForApproval[userID] = user
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue