@@ -48,30 +48,30 @@ func (b *Bot) Close(ctx context.Context) error {
48
48
return err
49
49
}
50
50
51
- func (b * Bot ) ExtractorAuth (ctx context.Context , tBot * bot.Bot , update * Update ) (context.Context , bool ) {
51
+ func (b * Bot ) ExtractorAuth (ctx context.Context , tBot * bot.Bot , update * Update ) (context.Context , error ) {
52
52
if b .AuthExtractor != nil {
53
53
info , err := b .AuthExtractor (ctx , update )
54
54
if err != nil {
55
55
if b .ErrorHandler != nil {
56
56
b .ErrorHandler (ctx , tBot , update , err )
57
57
}
58
- return nil , true
58
+ return nil , err
59
59
}
60
60
c := NewContext (ctx )
61
61
for k , v := range info {
62
62
c .SetValue (k , v )
63
63
}
64
- return c , false
64
+ return c , nil
65
65
}
66
- return ctx , false
66
+ return ctx , nil
67
67
}
68
68
69
69
func (b * Bot ) BindCommand (command string , handlerFunc HandlerFunc , middlewares ... MiddlewareFunc ) {
70
70
fn := WithMiddleware (handlerFunc , b .ErrorHandler , middlewares ... )
71
71
command = "/" + strings .TrimPrefix (command , "/" )
72
72
b .bot .RegisterHandler (bot .HandlerTypeMessageText , command , bot .MatchTypePrefix , func (ctx context.Context , tBot * bot.Bot , update * models.Update ) {
73
- ctx , done := b .ExtractorAuth (ctx , tBot , (* Update )(update ))
74
- if done {
73
+ ctx , err := b .ExtractorAuth (ctx , tBot , (* Update )(update ))
74
+ if err != nil {
75
75
return
76
76
}
77
77
fn (ctx , tBot , update )
@@ -81,8 +81,8 @@ func (b *Bot) BindCommand(command string, handlerFunc HandlerFunc, middlewares .
81
81
func (b * Bot ) BindCallback (route string , handlerFunc HandlerFunc , middlewares ... MiddlewareFunc ) {
82
82
fn := WithMiddleware (handlerFunc , b .ErrorHandler , middlewares ... )
83
83
b .bot .RegisterHandler (bot .HandlerTypeCallbackQueryData , route + ":" , bot .MatchTypePrefix , func (ctx context.Context , tBot * bot.Bot , update * models.Update ) {
84
- ctx , done := b .ExtractorAuth (ctx , tBot , (* Update )(update ))
85
- if done {
84
+ ctx , err := b .ExtractorAuth (ctx , tBot , (* Update )(update ))
85
+ if err != nil {
86
86
return
87
87
}
88
88
fn (ctx , tBot , update )
0 commit comments