Compare commits

...

3 commits

Author SHA1 Message Date
1f56246e8d goimports
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-21 21:08:39 -03:00
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
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 package main
import ( import (
"errors"
"io" "io"
"log" "log"
"net/http" "net/http"
@ -8,7 +9,6 @@ import (
"os" "os"
"strings" "strings"
"unicode/utf16" "unicode/utf16"
"errors"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"nulo.in/dlbot/common" "nulo.in/dlbot/common"
@ -44,6 +44,13 @@ func (fu FileURL) SendData() string {
func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) { func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) {
var explicit bool 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 msg := update.Message
if strings.HasPrefix(msg.Text, "/dl") || msg.Chat.IsPrivate() { if strings.HasPrefix(msg.Text, "/dl") || msg.Chat.IsPrivate() {
explicit = true explicit = true
@ -108,7 +115,7 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
} }
if érror == common.HadError { 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 continue
} }
} }
@ -162,7 +169,6 @@ func respondWith(msg *tgbotapi.Message, str string) tgbotapi.MessageConfig {
res := tgbotapi.NewMessage(msg.Chat.ID, str) res := tgbotapi.NewMessage(msg.Chat.ID, str)
res.ReplyToMessageID = msg.MessageID res.ReplyToMessageID = msg.MessageID
res.DisableWebPagePreview = true res.DisableWebPagePreview = true
res.ParseMode = "markdown"
return res return res
} }