Add support for inline requests

This commit is contained in:
Hamcha 2018-10-31 16:14:12 +01:00
parent fee485fe6d
commit 11a0947e7b
Signed by: hamcha
GPG Key ID: A40413D21021EAEE
1 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ type Mod struct {
Description string Description string
OnInit func() OnInit func()
OnMessage func(*tg.Broker, tg.APIMessage) OnMessage func(*tg.Broker, tg.APIMessage)
OnInline func(*tg.Broker, tg.APIInlineQuery)
Help func(*tg.Broker, tg.APIMessage) Help func(*tg.Broker, tg.APIMessage)
} }
@ -97,10 +98,13 @@ func initmods() {
log.Println("Active modules: " + strings.Join(enabledmods, ", ")) log.Println("Active modules: " + strings.Join(enabledmods, ", "))
} }
func dispatch(broker *tg.Broker, update tg.APIMessage) { func dispatch(broker *tg.Broker, update tg.APIUpdate) {
for _, mod := range mods { for _, mod := range mods {
if mod.OnInline != nil {
go mod.OnInline(broker, *update.Inline)
}
if mod.OnMessage != nil { if mod.OnMessage != nil {
go mod.OnMessage(broker, update) go mod.OnMessage(broker, *update.Message)
} }
} }
} }