bloaterbot

This commit is contained in:
Watn3y 2023-03-05 04:20:17 +01:00
parent 52f69d518a
commit d53b439455
15 changed files with 452 additions and 0 deletions

41
text/nhentai/nhentai.go Normal file
View file

@ -0,0 +1,41 @@
package nhentai
import (
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"regexp"
"strconv"
"watn3y/bloaterbotv3/botIO"
"watn3y/bloaterbotv3/config"
)
func Nhentai(regex string, update tgbotapi.Update, bot *tgbotapi.BotAPI) {
re := regexp.MustCompile(regex)
getdigit := regexp.MustCompile("\\d{2,}")
match := re.FindStringSubmatch(update.Message.Text)
hentainumber := getdigit.FindStringSubmatch(match[0])
hentaiExists, hentaiResponse := doAPIRequest(hentainumber[0])
if !hentaiExists {
return
}
hentai := parseAPIResponse(hentaiResponse)
var tags string
for _, tag := range hentai.Tags {
tags = tags + `<a href="` + config.BotConfig.Nhentai.Domain + tag.URL + `">` + tag.Name + `</a>` + `, `
}
println(tags)
hentaitext := `<b>` + `<a href="` + config.BotConfig.Nhentai.Domain + `/g/` + strconv.Itoa(hentai.ID) + `">` + hentai.Title + `</a> ` + `</b>` + "\n\n" + tags
message := tgbotapi.MessageConfig{
BaseChat: tgbotapi.BaseChat{ChatID: update.Message.Chat.ID, ReplyToMessageID: update.Message.MessageID},
ParseMode: "html",
DisableWebPagePreview: false,
Text: hentaitext,
}
botIO.SendMessage(message, bot)
}