Skip to content

Commit

Permalink
implement actual unban
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 6, 2023
1 parent 2c0daf8 commit cb7928f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/events/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,19 @@ func (l *TelegramListener) runUnbanServer(ctx context.Context) {
return
}
log.Printf("[INFO] unban user %s (%d)", id, userID)
_, err = l.TbAPI.Request(tbapi.UnbanChatMemberConfig{ChatMemberConfig: tbapi.ChatMemberConfig{UserID: userID, ChatID: l.chatID}})
if err != nil {
log.Printf("[WARN] failed to unban %s, %v", id, err)
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "failed to unban %s: %v", id, err)
return
}
if _, err := w.Write([]byte("ok")); err != nil {
log.Printf("[WARN] failed to write response, %v", err)
}
})

// run server cancelable with context
srv := &http.Server{
Addr: l.AdminListenAddr,
Handler: mux,
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
}
srv := &http.Server{Addr: l.AdminListenAddr, Handler: mux, ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second}

go func() {
<-ctx.Done()
Expand Down

0 comments on commit cb7928f

Please sign in to comment.