Compare commits

...

3 commits

Author SHA1 Message Date
Cat /dev/Nulo 1f56246e8d goimports
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-21 21:08:39 -03:00
Cat /dev/Nulo 2b83114148 no usar parsemode markdown
aparentemente el markdown de telegram tira errores (?) cuando tenés guiones bajos sin "cerrar"
2023-06-21 21:08:33 -03:00
Cat /dev/Nulo ca70ad20e9 reportar errores cuando falla enviar un mensaje 2023-06-21 21:08:04 -03:00

12
main.go
View file

@ -1,6 +1,7 @@
package main
import (
"errors"
"io"
"log"
"net/http"
@ -8,7 +9,6 @@ import (
"os"
"strings"
"unicode/utf16"
"errors"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"nulo.in/dlbot/common"
@ -44,6 +44,13 @@ func (fu FileURL) SendData() string {
func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) {
var explicit bool
send := func(c tgbotapi.Chattable) {
_, err := bot.Send(c)
if err != nil {
log.Println("No pude enviar un mensaje porque", err)
}
}
msg := update.Message
if strings.HasPrefix(msg.Text, "/dl") || msg.Chat.IsPrivate() {
explicit = true
@ -108,7 +115,7 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
}
if érror == common.HadError {
bot.Send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
continue
}
}
@ -162,7 +169,6 @@ func respondWith(msg *tgbotapi.Message, str string) tgbotapi.MessageConfig {
res := tgbotapi.NewMessage(msg.Chat.ID, str)
res.ReplyToMessageID = msg.MessageID
res.DisableWebPagePreview = true
res.ParseMode = "markdown"
return res
}