Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Готовые хендлеры для User Longpoll V10 #87

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

tdakkota
Copy link
Contributor

#81

longpoll-user/v10/wrapper.go Outdated Show resolved Hide resolved
longpoll-user/v10/wrapper.go Outdated Show resolved Hide resolved
longpoll-user/v10/wrapper.go Outdated Show resolved Hide resolved
longpoll-user/v10/wrapper.go Outdated Show resolved Hide resolved
longpoll-user/v10/wrapper.go Outdated Show resolved Hide resolved
longpoll-user/v3/flags.go Outdated Show resolved Hide resolved
longpoll-user/v10/flags.go Outdated Show resolved Hide resolved
longpoll-user/v10/flags.go Outdated Show resolved Hide resolved
longpoll-user/v10/extra.go Outdated Show resolved Hide resolved
longpoll-user/v10/objects.go Outdated Show resolved Hide resolved
@SevereCloud SevereCloud added this to the v1.4 milestone Feb 27, 2020
@SevereCloud SevereCloud self-requested a review March 15, 2020 11:26
scripts/longpoll-wrapper/wrapper_header.text Show resolved Hide resolved
Comment on lines +5 to +8
// Wrapper struct
type Wrapper struct {
longpoll *longpoll.Longpoll
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longpoll приватное поле, которое нельзя установить

Suggested change
// Wrapper struct
type Wrapper struct {
longpoll *longpoll.Longpoll
}
// Wrapper struct
type Wrapper struct {
longpoll *longpoll.Longpoll
}
// NewWrapper return *Wrapper for longpoll v10
func NewWrapper(lp *longpoll.Longpoll) *Wrapper {
lp.Version = 10
return &Wrapper{longpoll: lp}
}

Comment on lines 33 to 35
if v, ok := i[3].(float64); ok {
result.MessageID = int(v)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Структура: [2, msg_id, flags, peer_id]

Suggested change
if v, ok := i[3].(float64); ok {
result.MessageID = int(v)
}
if v, ok := i[3].(float64); ok {
result.PeerID = int(v)
}

longpoll-user/v10/objects.go Show resolved Hide resolved
longpoll-user/v10/objects.go Show resolved Hide resolved
Comment on lines 145 to 147
if length < 11 {
return fmt.Errorf(errFmtTooShortArray, structName, 11, length)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random_id передается только при mode 128, поэтому в событии может быть 10 элементов!

cannot parse array into Go struct MessageFlagsReset: expected at least 11 element(s), got 10

[3,1925,32832,219343149,1582686175,"доброго вечера, я хотел бы задать вопрос по вашей новой группе вк. ок?",{"title":" ... "},{},1,0]

Comment on lines 177 to 179
if v, ok := i[8].(float64); ok {
result.RandomID = int(v)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random_id передается только при mode 128

  • [4,2467,49,117253521,1584275213,"f",{"title":" ... "},{},23,0]
  • [5,2467,48,117253521,1584275213,"ff",{"title":""},{},23,1584275218]
  • [3,2467,32832,117253521,1584275213,"ff",{"title":""},{},23,1584275218]

Сообщение

{
   "date": 1584275213,
   "from_id": 117253521,
   "id": 4998010,
   "out": 1,
   "peer_id": 540042353,
   "text": "ff",
   "conversation_message_id": 23,
   "fwd_messages": [],
   "important": false,
   "random_id": 868652978,
   "attachments": [],
   "is_hidden": false,
   "update_time": 1584275218,
   "conversation_keyboard": null
}

Comment on lines 48 to 50
func (result *MessageFlagsReset) Parse(i []interface{}) error {
return result.parseMessage("MessageFlagsReset", i)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможные значения флагов сообщения:

Прочитано сообщение (unread). Не рекомендую использовать, потому что иногда этот флаг не приходит
Отмена пометки важным (important)
Отмена пометки сообщения как спам (spam и cancel_spam)
Восстановление удаленного сообщения (deleted)
В 1 и 2 случаях структура у события такая: [3, msg_id, flags, peer_id].
В 3 и 4 случаях возвращается сообщение.


[3,2466,8,117253521]

cannot parse array into Go struct MessageFlagsReset: expected at least 11 element(s), got 4

longpoll-user/v10/objects.go Show resolved Hide resolved
Comment on lines 400 to 403
event := NotificationSettingsChange{}
if err := event.Parse(i); err != nil {
return err
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

При mode=10

cannot parse array into Go struct NotificationSettingsChange: expected at least 3 element(s), got 2

Suggested change
event := NotificationSettingsChange{}
if err := event.Parse(i); err != nil {
return err
}
event := NotificationSettingsChange{}
if w.longpoll.Mode & longpoll.ExtendedEvents != 0 {
if err := event.ParseMode8(i); err != nil {
return err
}
} else {
if err := event.Parse(i); err != nil {
return err
}
}

Тут нужно еще добавить в импорт longpoll

@SevereCloud SevereCloud added the enhancement New feature or request label Mar 16, 2020
if len(i) < 4 {
return fmt.Errorf(errFmtTooShortArray, "MessageFlagsReset", 4, len(i))
}
return result.parseMessage("MessageFlagsReset", i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return statements should not be cuddled if block has more than two lines (from wsl)

@SevereCloud SevereCloud removed this from the v1.5 milestone Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants