Skip to content

Commit

Permalink
Export update processing internals to allow for handling manually cra…
Browse files Browse the repository at this point in the history
…fted updates
  • Loading branch information
PaulSonOfLars committed Nov 7, 2020
1 parent 993f9be commit ef1b6e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (d Dispatcher) Start() {
limiter <- struct{}{} // make sure to send anyway
}
go func(upd *RawUpdate) {
d.processUpdate(upd)
d.ProcessRawUpdate(upd)
<-limiter
}(upd)
}
Expand All @@ -59,7 +59,7 @@ type ContinueGroups struct{}
func (eg EndGroups) Error() string { return "Group iteration ended" }
func (eg ContinueGroups) Error() string { return "Group iteration has continued" }

func (d Dispatcher) processUpdate(upd *RawUpdate) {
func (d Dispatcher) ProcessRawUpdate(upd *RawUpdate) {
defer func() {
if r := recover(); r != nil {
d.Bot.Logger.Error(r)
Expand All @@ -72,6 +72,10 @@ func (d Dispatcher) processUpdate(upd *RawUpdate) {
d.Bot.Logger.Errorw("failed to init update while processing", zap.Error(err))
return
}
d.ProcessUpdate(update)
}

func (d Dispatcher) ProcessUpdate(update *Update) {
for _, groupNum := range *d.handlerGroups {
for _, handler := range d.handlers[groupNum] {
if res, err := handler.CheckUpdate(update); res {
Expand Down

0 comments on commit ef1b6e8

Please sign in to comment.