This repository has been archived on 2024-01-17. You can view files and clone it, but cannot push or open issues or pull requests.
dlbot4/tiktok/main.go

41 lines
898 B
Go
Raw Normal View History

2022-08-10 18:41:51 +00:00
package main
import (
"log"
"net/url"
2023-01-03 02:02:17 +00:00
"nulo.in/dlbot/common"
2022-08-10 18:41:51 +00:00
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
// Gracias a https://github.com/Xenzi-XN1/Tiktok-Download
// por enseñarme tikmate.app
2023-01-03 02:02:17 +00:00
func respond(bot *tgbotapi.BotAPI, update tgbotapi.Update, url *url.URL) common.Result {
if url.Hostname() != "vm.tiktok.com" && url.Hostname() != "tiktok.com" {
return common.NotValid
2022-08-10 18:41:51 +00:00
}
2023-01-03 02:02:17 +00:00
urlString := url.String()
2022-08-10 18:41:51 +00:00
2023-01-03 02:02:17 +00:00
// tikmate no entiende tiktok.com
url.Host = "vm.tiktok.com"
2022-08-10 18:41:51 +00:00
2023-01-03 02:02:17 +00:00
log.Printf("Downloading %s", urlString)
lookup, err := Lookup(url.String())
if err != nil {
log.Println(err)
2023-01-03 02:02:17 +00:00
return common.HadError
2022-08-10 18:41:51 +00:00
}
2023-01-03 02:02:17 +00:00
log.Println(lookup)
2022-08-10 18:41:51 +00:00
res := tgbotapi.NewVideo(update.Message.Chat.ID, tgbotapi.FileURL(lookup))
2023-01-03 02:02:17 +00:00
res.ReplyToMessageID = update.Message.MessageID
bot.Send(res)
return common.Uploaded
2022-08-10 18:41:51 +00:00
}
func main() {
2023-01-03 02:02:17 +00:00
common.Main(common.Config{Respond: respond})
2022-08-10 18:41:51 +00:00
}