Compare commits

..

No commits in common. "1f56246e8d724bdd59bce35408349ab6bbd9d9d8" and "702519ddc77d0ad650c69f809c9ca871a61cbb57" have entirely different histories.

12
main.go
View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"errors"
"io" "io"
"log" "log"
"net/http" "net/http"
@ -9,6 +8,7 @@ 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,13 +44,6 @@ 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
@ -115,7 +108,7 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
} }
if érror == common.HadError { if érror == common.HadError {
send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), ".")) bot.Send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
continue continue
} }
} }
@ -169,6 +162,7 @@ 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
} }