GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bot/process_update.go at main · go-telegram/bot

Expand file tree

/

process_update.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
48 lines (38 loc) · 942 Bytes
/

process_update.go

Copy path

File metadata and controls

48 lines (38 loc) · 942 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bot
import (
"context"
"github.com/go-telegram/bot/models"
)
func applyMiddlewares(h HandlerFunc, m ...Middleware) HandlerFunc {
if len(m) < 1 {
return h
}
wrapped := h
for i := len(m) - 1; i >= 0; i-- {
wrapped = m[i](wrapped)
}
return wrapped
}
// ProcessUpdate finds the handler for upd, applies the bot middlewares and runs
// it. The handler runs in a new goroutine, or in the calling goroutine with
// WithNotAsyncHandlers.
func (b *Bot) ProcessUpdate(ctx context.Context, upd *models.Update) {
h := b.findHandler(upd)
r := applyMiddlewares(h, b.middlewares...)
if b.notAsyncHandlers {
r(ctx, b, upd)
return
}
go r(ctx, b, upd)
}
func (b *Bot) findHandler(upd *models.Update) HandlerFunc {
b.handlersMx.RLock()
defer b.handlersMx.RUnlock()
usernames := b.botUsernames()
for _, h := range b.handlers {
if h.match(upd, usernames...) {
return h.handler
}
}
return b.defaultHandlerFunc
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.