diff --git a/mods/main.go b/mods/main.go index a6a50a0..77ba7ff 100644 --- a/mods/main.go +++ b/mods/main.go @@ -72,7 +72,7 @@ func initmods() { func dispatch(broker *tg.Broker, update tg.APIMessage) { for _, mod := range mods { if mod.OnMessage != nil { - mod.OnMessage(broker, update) + go mod.OnMessage(broker, update) } } } diff --git a/mods/stt.go b/mods/stt.go index 15ceced..6925950 100644 --- a/mods/stt.go +++ b/mods/stt.go @@ -32,6 +32,12 @@ func stt(broker *tg.Broker, update tg.APIMessage) { update.Voice = update.ReplyTo.Voice } + // Make sure it's a voice message + if update.Voice == nil { + broker.SendTextMessage(update.Chat, "Non vedo un messaggio vocale da ascoltare", &update.MessageID) + return + } + if update.Voice.Duration > 60 { broker.SendTextMessage(update.Chat, "L'audio dura un bel po' (> 1 minuto), al momento non posso farci nulla :S", &update.MessageID) return