mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-09-06 08:06:56 +08:00
fix(bot): stopped swallowing callbacks on permission pass
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/celestix/gotgproto/dispatcher"
|
"github.com/celestix/gotgproto/dispatcher"
|
||||||
"github.com/celestix/gotgproto/ext"
|
"github.com/celestix/gotgproto/ext"
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
@@ -37,10 +39,12 @@ func checkPermission(ctx *ext.Context, update *ext.Update) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// withPermission wraps a callback handler with the same whitelist check used
|
// withPermission wraps a callback handler with the same whitelist check used
|
||||||
// for message handlers (checkPermission).
|
// for message handlers (checkPermission). ContinueGroups is the dispatcher's
|
||||||
|
// success sentinel, not an error: only real failures and EndGroups stop the
|
||||||
|
// chain before the wrapped handler runs.
|
||||||
func withPermission(handler func(*ext.Context, *ext.Update) error) func(*ext.Context, *ext.Update) error {
|
func withPermission(handler func(*ext.Context, *ext.Update) error) func(*ext.Context, *ext.Update) error {
|
||||||
return func(ctx *ext.Context, update *ext.Update) error {
|
return func(ctx *ext.Context, update *ext.Update) error {
|
||||||
if err := checkPermission(ctx, update); err != nil {
|
if err := checkPermission(ctx, update); err != nil && !errors.Is(err, dispatcher.ContinueGroups) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return handler(ctx, update)
|
return handler(ctx, update)
|
||||||
|
|||||||
Reference in New Issue
Block a user