-
Notifications
You must be signed in to change notification settings - Fork 0
/
nadmozg_bot.go
76 lines (62 loc) · 1.75 KB
/
nadmozg_bot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"log"
"github.com/Syfaro/telegram-bot-api"
//"strings"
"strings"
"regexp"
//"time"
//"math/rand"
)
func main() {
bot, err := tgbotapi.NewBotAPI("519585678:AAF5Eg-_ODEaGTgcIKhsbgPVKt4vfUb_sF4")
if err != nil {
log.Panic(err)
}
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
//bot.GetUp
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
//sr := rand.NewSource(time.Now().UnixNano())
//r1 := rand.New(sr)
chatMessage := update.Message.Text
//regexp1 := regexp.MustCompile("(?i)бот")
result, _ := regexp.MatchString("(?i)бот|слыш", chatMessage)
log.Println(result)
if result {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, gopnicAnswer())
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
continue
}
result, _ = regexp.MatchString("(?i)^нет$", chatMessage)
log.Println(result)
if result {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Пидора ответ!")
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
continue
}
if (len(strings.Split(update.Message.Text, " ")) == 1) && probably(20) {
lex_redupl, err := huifma(update.Message.Text)
if err == nil {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, lex_redupl)
//msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
}
continue
}
if probably(15 ) {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, gopnicAnswer())
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
}
}
}