diff --git a/README.md b/README.md index 0487320..1c2a2e0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ Library with states, goroutines ## Example ```go + +const ( + groupID = 1234568 + token = "token" +) + type stateFn func(event *gvk.Update) stateFn type Bot struct { @@ -14,11 +20,6 @@ type Bot struct { gvk.API } -const ( - groupID = 1234567 - token = "token here" -) - func newBot(chatID int64) gvk.Bot { b := &Bot{ chatID: chatID, @@ -34,20 +35,21 @@ func (b *Bot) Update(update *gvk.Update) { } func (b *Bot) EntryHandler(update *gvk.Update) stateFn { - if strings.HasPrefix(update.MessageNew.Message.Text, "ping") { - b.MessagesSend("pong", &gvk.MessagesSendOptions{UserID: b.chatID}) + if strings.HasPrefix(update.Object.MessageNew.Message.Text, "ping") { + b.MessagesSend(&gvk.MessagesSendOptions{Message: "pong", UserID: b.chatID}) return b.handleNext } - b.MessagesSend("not understand...", &gvk.MessagesSendOptions{UserID: b.chatID,}) + b.MessagesSend(&gvk.MessagesSendOptions{Message: "not understand...", UserID: b.chatID}) return b.EntryHandler } func (b *Bot) handleNext(update *gvk.Update) stateFn { - b.name = update.MessageNew.Message.Text - b.MessagesSend("pong again )))", &gvk.MessagesSendOptions{ - UserID: b.chatID,}) + b.MessagesSend(&gvk.MessagesSendOptions{ + Message: "pong again )))", + UserID: b.chatID, + }) return b.EntryHandler } diff --git a/dispatcher.go b/dispatcher.go index 5c2d495..04f19b1 100644 --- a/dispatcher.go +++ b/dispatcher.go @@ -74,7 +74,7 @@ func (d *Dispatcher) PollOptions(dropPendingUpdates bool) error { for { //TODO: сброс апдейтов - time.Sleep(100 * time.Millisecond) + time.Sleep(50 * time.Millisecond) result, err := d.api.GetUpdates(&d.opts) if err != nil { diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/options.go b/options.go index 0306b50..e796cdc 100644 --- a/options.go +++ b/options.go @@ -16,8 +16,8 @@ type MessagesSendOptions struct { Message string `query:"message"` UserID int64 `query:"user_id"` Keyboard Keyboard `query:"keyboard"` - DontParseLinks int64 `json:"dont_parse_links"` - DisableMentions int64 `json:"disable_mentions"` + DontParseLinks int64 `json:"dont_parse_links"` // 1 - true, 0 - false + DisableMentions int64 `json:"disable_mentions"` // 1 - true, 0 - false } type MessagesEditOptions struct { diff --git a/responses.go b/responses.go index 70b6cb7..40105ba 100644 --- a/responses.go +++ b/responses.go @@ -186,9 +186,9 @@ func (u *Update) ChatID() int64 { } func (a RawUpdates) UnmarshalCustom() (Updates, error) { - if len(a) > 0 { - fmt.Println("COUNT UPDATES", len(a)) - } + //if len(a) > 0 { + // fmt.Println("COUNT UPDATES", len(a)) + //} var updates Updates for _, row := range a {