-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: master
Are you sure you want to change the base?
Conversation
// Wrapper struct | ||
type Wrapper struct { | ||
longpoll *longpoll.Longpoll | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Longpoll приватное поле, которое нельзя установить
// 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} | |
} |
longpoll-user/v10/objects.go
Outdated
if v, ok := i[3].(float64); ok { | ||
result.MessageID = int(v) | ||
} |
There was a problem hiding this comment.
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]
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/extra.go
Outdated
if length < 11 { | ||
return fmt.Errorf(errFmtTooShortArray, structName, 11, length) | ||
} |
There was a problem hiding this comment.
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]
longpoll-user/v10/extra.go
Outdated
if v, ok := i[8].(float64); ok { | ||
result.RandomID = int(v) | ||
} |
There was a problem hiding this comment.
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
}
longpoll-user/v10/objects.go
Outdated
func (result *MessageFlagsReset) Parse(i []interface{}) error { | ||
return result.parseMessage("MessageFlagsReset", i) | ||
} |
There was a problem hiding this comment.
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/wrapper.go
Outdated
event := NotificationSettingsChange{} | ||
if err := event.Parse(i); err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
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
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
if len(i) < 4 { | ||
return fmt.Errorf(errFmtTooShortArray, "MessageFlagsReset", 4, len(i)) | ||
} | ||
return result.parseMessage("MessageFlagsReset", i) |
There was a problem hiding this comment.
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
)
#81