GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — bot/process_update.go at main · go-telegram/bot Expand file tree/ Copy pathprocess_update.goMore file actions 48 lines (38 loc) · 942 Bytes / Copy pathprocess_update.goFile metadata and controls48 lines (38 loc) · 942 Bytes 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. |