Compare commits

...

2 commits

Author SHA1 Message Date
2d02edf907 resubir a mano
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-05-09 20:40:54 -03:00
2e61e51be9 reportar errores subiendo a telegram 2023-05-09 20:40:43 -03:00
2 changed files with 26 additions and 3 deletions

27
main.go
View file

@ -1,7 +1,9 @@
package main package main
import ( import (
"io"
"log" "log"
"net/http"
"net/url" "net/url"
"os" "os"
"strings" "strings"
@ -16,6 +18,24 @@ type Config struct {
Responders []common.Responder Responders []common.Responder
} }
type FileURL string
func (fu FileURL) NeedsUpload() bool {
return true
}
func (fu FileURL) UploadData() (string, io.Reader, error) {
res, err := http.Get(string(fu))
if err != nil {
return "", nil, err
}
return "url.mp4", res.Body, nil
}
func (fu FileURL) SendData() string {
panic("we")
}
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
@ -58,10 +78,13 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
} }
if uploadable != nil { if uploadable != nil {
res := tgbotapi.NewVideo(update.Message.Chat.ID, tgbotapi.FileURL(uploadable.Url)) res := tgbotapi.NewVideo(update.Message.Chat.ID, FileURL(uploadable.Url))
res.ReplyToMessageID = update.Message.MessageID res.ReplyToMessageID = update.Message.MessageID
res.Caption = uploadable.Caption res.Caption = uploadable.Caption
bot.Send(res) _, err := bot.Send(res)
if err != nil {
log.Println("Error subiendo", url.String(), err)
}
} }
if explicit && érror == common.NotValid { if explicit && érror == common.NotValid {

View file

@ -2,7 +2,7 @@ Un bot para Telegram que permite descargar videos de distintos lugares.
[@dlthefourthbot](https://t.me/dlthefourthbot) [@dlthefourthbot](https://t.me/dlthefourthbot)
Es rápido ya que ni siquiera descarga el video, solo le pasa a Telegram la URL para descargarlos. ~~Es rápido ya que ni siquiera descarga el video, solo le pasa a Telegram la URL para descargarlos.~~ 2023-05-09: parece que Telegram bloquea urls de Instagram y TikMate con el error `Bad Request: wrong file identifier/HTTP URL specified`, tenemos que resubir manualmente :(
## TikTok ## TikTok