37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package text
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"watn3y.de/bloaterbot/commonlogic"
|
|
"watn3y.de/bloaterbot/config"
|
|
"watn3y.de/bloaterbot/text/balonlyl"
|
|
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
// TODO logging
|
|
func Matcher(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
|
|
|
log.Debug().Str("Text", update.Message.Text).Msg("Starting text matcher")
|
|
|
|
if time.Since(config.BotConfig.Shutup[update.Message.Chat.ID]) <= time.Minute*60 {
|
|
log.Debug().Str("text", update.Message.Text).Int64("chat", update.Message.Chat.ID).Msg("Aborting due to shut-up")
|
|
return
|
|
}
|
|
//balonlyl
|
|
var isBalonlyl = false
|
|
for _, word := range config.BotConfig.Balonlyl.TriggerWords {
|
|
if strings.Contains(strings.ToLower(update.Message.Text), word) && (commonlogic.ContainsInt64(config.BotConfig.Balonlyl.EnabledChats, update.Message.Chat.ID)) {
|
|
isBalonlyl = true
|
|
break
|
|
}
|
|
}
|
|
if isBalonlyl {
|
|
log.Info().Str("text", update.Message.Text).Int64("chat", update.Message.Chat.ID).Msg("Matched text in message")
|
|
go balonlyl.Balonlyl(update, bot)
|
|
}
|
|
|
|
}
|