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

View file

@ -15,6 +15,7 @@ type Mod struct {
Description string
OnInit func()
OnMessage func(*tg.Broker, tg.APIMessage)
OnInline func(*tg.Broker, tg.APIInlineQuery)
Help func(*tg.Broker, tg.APIMessage)
}
@ -97,10 +98,13 @@ func initmods() {
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 {
if mod.OnInline != nil {
go mod.OnInline(broker, *update.Inline)
}
if mod.OnMessage != nil {
go mod.OnMessage(broker, update)
go mod.OnMessage(broker, *update.Message)
}
}
}