go-dette/utils.go

43 lines
769 B
Go

package main
import (
"log"
"strings"
"time"
"git.nefrace.ru/nefrace/nechotron"
)
func StringHasAny(s string, subs ...string) bool {
for _, sub := range subs {
if strings.Contains(s, sub) {
return true
}
}
return false
}
func StringHasPrefix(s string, subs ...string) bool {
for _, sub := range subs {
if strings.HasPrefix(s, sub) {
return true
}
}
return false
}
func StringHasSuffix(s string, subs ...string) bool {
for _, sub := range subs {
if strings.HasSuffix(s, sub) {
return true
}
}
return false
}
func waitAndDelete(u *nechotron.Update, chatId int64, messageId int) {
time.Sleep(10 * time.Second)
if _, err := u.Bot.DeleteMessage(chatId, messageId); err != nil {
log.Println("Can't wait-delete message: ", err)
}
}