-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
89 lines (62 loc) · 1.59 KB
/
main.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
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"log"
"strings"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/loveyandex/chatbtc-telegram.git/flow"
)
func main() {
bot, err := tgbotapi.NewBotAPI("6279508336:AAGxO1241tiI9rQ31_-77JS8aXoJjkpIzXI")
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
updates := bot.GetUpdatesChan(u)
xxxxxx:
for update := range updates {
for _, t := range flow.NewCircuit() {
if update.Message != nil {
if update.Message.Text != "" {
for _, f := range t.TextFlows {
if f.Name == update.Message.Text {
f.Func(&update, bot)
continue xxxxxx
}
}
}
if update.Message.Contact != nil {
if t.ContactFlow != nil {
t.ContactFlow.Func(&update, bot, update.Message.Contact)
continue xxxxxx
}
}
}
if update.InlineQuery != nil {
if t.InlineQueryFLow.Splits == len(strings.Split(update.InlineQuery.Query, " ")) {
t.InlineQueryFLow.Func(&update, bot, update.InlineQuery.Query)
continue xxxxxx
}
}
if update.CallbackQuery != nil {
for _, isf := range t.PublicStringIncludeFlows {
if strings.Contains(update.CallbackQuery.Data, (isf.Include)) {
isf.Func(&update, bot, update.CallbackQuery.Data)
continue xxxxxx
}
}
}
}
if update.CallbackQuery != nil {
}
//no neeed to user state-transitions
if update.CallbackQuery != nil {
}
//user need automata
if update.SentFrom() == nil {
continue xxxxxx
}
}
}