Commit Graph

98 Commits

Author SHA1 Message Date
Timofey e7770fadda Add WebAppDataValidator for mini app init data
Checks window.WebApp.initData by the bot token as dev.max.ru/docs/webapps/validation
describes, then its age, and returns the data parsed. A repeated field is refused.
Bound in the Laravel service provider with the configured token.
2026-10-27 23:21:31 +05:00
Alex b0d87b80b0 Sync Laravel library 2026-10-01 13:02:21 +03:00
Alex 21f6cb9e83 Update tests and Throw InvalidArgumentException when building an empty comment body 2026-10-01 11:26:19 +03:00
Alex 591be47cc2 Merge branch 'master' into sync/api-schema-0.0.33 2026-10-01 10:32:49 +03:00
Alex fd878a45e7 Merge pull request #43 from smotim/fix/me-commands
feat: add editBotCommands for PATCH /me/commands, deprecate editBotInfo
2026-10-01 08:33:26 +03:00
Alex 919970fa20 Convert non-array update payloads to LogicException instead of TypeError 2026-09-30 23:40:03 +03:00
Timofey dd00b4c5e6 Allow comment_removed without post_id
The schema lists post_id as required, but the official TypeScript
client types it as `string | null`. A null would fail with a TypeError
and, unlike an unknown update type, TypeError is not caught while
parsing updates.
2026-10-01 01:10:45 +05:00
Timofey d9ec52fc53 Add disableLinkPreview to answerOnCallback
POST /answers got the disable_link_preview query parameter in August
2026. It is sent only when true, so default requests are unchanged.
2026-10-01 01:10:45 +05:00
Timofey 96dea75530 Deprecate what the API no longer has
Methods (per the API changelog and schema 0.0.33):
- getChats(): GET /chats is not supported since June 2026
- getChatByLink(), deleteChat(): no longer documented, absent from
  the schema
- addMembers(): POST /chats/{chatId}/members is limited since
  9 September 2026 and removed on 30 September 2026

Models and enums absent from schema 0.0.33: the chat inline button,
reply buttons and ReplyButtonType, Intent, MessageChatCreatedUpdate
and its handlers, Chat::$chatMessageId.

Only @deprecated tags and docs; nothing is removed, so existing code
keeps working until a major release. README coverage map updated.
2026-10-01 01:10:45 +05:00
Timofey c8f3b8e33d Add comments API
Schema 0.0.33 adds comments to channel posts:

- GET    /messages/{messageId}/comments               getComments()
- GET    /messages/{messageId}/comments/{commentId}   getCommentById()
- POST   /messages/{messageId}/comments               sendComment()
- PUT    /messages/{messageId}/comments               editComment()
- DELETE /messages/{messageId}/comments               deleteComment()

Comments get their own models (CommentMessage, CommentMessageBody,
CommentLinkedMessage): unlike Message they have no attachments and
no public URL. README coverage map and docs updated.
2026-10-01 01:10:45 +05:00
Timofey 1bfeb17a15 Add fields and markup added in schema 0.0.33
- Recipient::$postId: the commented post, set for comments
- ContactAttachmentPayload::$hash: hash of the VCF info
- ChatPatch: document the description field (up to 16000 chars,
  empty string removes it)
- QuoteMarkup and MarkupType::Quote. createMarkupElement() threw
  "Unknown or unsupported markup type" on a quote block, so a message
  with a quote could not be parsed at all

New constructor parameters are optional and last, so existing
positional calls keep working; toArray() of these models now also
carries the new keys.
2026-10-01 01:10:45 +05:00
Timofey d1637add72 Parse comment and bot admin permission updates
UpdateType already had comment_created, comment_edited,
comment_removed and bot_admin_permissions_changed, but ModelFactory
had no models for them and threw "Unknown or unsupported update type".
Adds the models from schema 0.0.33, maps them in createUpdate() and
adds on*() shortcuts to UpdateDispatcher and MaxBotManager.
2026-10-01 01:10:45 +05:00
Timofey 749c0aab5b Allow users without last_activity_time
Since schema 0.0.33 User.last_activity_time is nullable and not
required. AbstractUser and its subclasses declared it as int, so a
user object without it failed with "Argument #6 ($lastActivityTime)
must be of type int, null given" and took the whole update with it.
2026-10-01 01:10:28 +05:00
Timofey ca5ed4c100 Add editBotCommands for PATCH /me/commands, deprecate editBotInfo
The API no longer accepts PATCH /me: it answers "Path /me is not
recognized", so editBotInfo() fails, including for commands. Commands
now have their own endpoint, PATCH /me/commands (editMyCommands in the
official schema); bot name, description and photo are edited on the
MAX partner platform.

- Api::editBotCommands(BotCommand[]): BotCommandsInfo
- BotCommandsInfo model and ModelFactory::createBotCommandsInfo()
- editBotInfo() and BotPatch marked @deprecated
- README coverage map and docs updated
2026-10-01 01:10:28 +05:00
Timofey a50e5be823 Skip updates that do not fit their model instead of crashing
#17 made unsupported update types silent: createUpdate() throws a
LogicException, and createUpdateList() and WebhookHandler log it and
skip the update. An update of a known type whose payload no longer
fits the model (the API made a field optional, added an enum value)
fails earlier, with a TypeError or ValueError from the model
constructor, and nothing catches those:

- createUpdateList() lets it out of getUpdates(), and
  LongPollingHandler::handle() catches only \Exception, so the loop
  stops and restarts into the same batch
- WebhookHandler answers 500 and MAX keeps retrying

createUpdate() now turns TypeError and ValueError into a
LogicException (the original one kept as previous) and logs a warning
with the payload, so the existing silent mode skips such an update.
Errors thrown by user handlers are not affected.
2026-09-28 00:34:08 +05:00
Timofey e431046a1a Add editBotCommands for PATCH /me/commands, deprecate editBotInfo
The API no longer accepts PATCH /me: it answers "Path /me is not
recognized", so editBotInfo() fails, including for commands. Commands
now have their own endpoint, PATCH /me/commands (editMyCommands in the
official schema); bot name, description and photo are edited on the
MAX partner platform.

- Api::editBotCommands(BotCommand[]): BotCommandsInfo
- BotCommandsInfo model and ModelFactory::createBotCommandsInfo()
- editBotInfo() and BotPatch marked @deprecated
- README coverage map and docs updated
2026-09-28 00:08:35 +05:00
Semion Zuev d1351ab21b Merge branch 'BushlanovDev:master' into master 2026-09-09 14:53:36 +03:00
szuev 93169320f7 new update types 2026-09-09 14:51:50 +03:00
Alex 4516db5ffd Refactoring base url #38 2026-07-26 12:56:32 +03:00
Alexei Panov caecb3f444 add new chat admin permission constants 2026-07-22 23:08:31 +04:00
Alex 10a7ef1ef8 tag 1.6.5 2026-07-19 09:29:19 +03:00
yakoffKa 865eb56aca Change url address 2026-07-17 09:49:59 +03:00
Alex e5a6ec40fc Update composer 2026-06-27 16:40:46 +03:00
Konstantin 40de64593b Change url address
Для корректной работы ваших чат-ботов и мини-приложений до 19 июля 2026 необходимо перенаправить HTTP-запросы с домена platform-api.max.ru на platform-api2.max.ru, а также добавить сертификат Минцифры в список доверенных
2026-06-25 12:53:49 +03:00
Alex dfe2147cd1 tag 1.6.3 2026-04-26 20:36:38 +03:00
Alex 3d958f3f92 Update tests 2026-04-26 20:28:07 +03:00
imperiumbee b726c96366 Merge branch 'BushlanovDev:master' into master 2026-04-25 18:41:05 +03:00
imperiumbee c41221cec7 New button type clipboard 2026-04-25 18:38:55 +03:00
Alex 4fdfca53ee tag 1.6.2 2026-04-17 20:21:29 +03:00
Alex efd6261490 Added chat admin permissions 2026-04-15 22:10:15 +03:00
Alex dd295efc3d tag 1.6.0 2026-03-22 09:23:35 +03:00
Alex 85231b0962 Removed deprecated DataAttachment 2026-03-21 09:44:40 +03:00
Alex 40742ddc60 Removed deprecated ReplyKeyboardAttachment #27 2026-03-20 22:55:36 +03:00
Alex affe904bed tag 1.5.1 2026-03-07 09:47:01 +03:00
imperiumbee 3eb3e07bfa Added payload param to openAppButton 2026-03-06 11:12:20 +03:00
Alex 2a97a15889 1.5.0 2025-12-20 20:36:59 +03:00
Alex 67463a6b64 Replacing the User object with UserWithPhoto #22 2025-12-19 13:30:36 +03:00
Alex 3c6da8e8f6 Added MessageButton & ChatAdminPermission::EditLink & alias in ChatAdmin & participants in Chat & first_name in BotPatch 2025-12-18 19:50:58 +03:00
Alex a7773c0b93 Added AttachmentNotReadyException (#19) 2025-12-06 15:15:39 +03:00
Alex 79d406da27 ShareAttachmentRequestPayload & PhotoAttachmentRequestPayload update exception rule (#18) 2025-12-05 13:53:07 +03:00
Alex ef3b76394c tag 1.4.0 2025-12-04 08:44:10 +03:00
Alex 2e7e9d987f Added DialogUnmuted & DialogCleared & DialogRemoved update types 2025-12-03 23:05:09 +03:00
Alex cf415b70e9 Added DialogMuted & BotStopped update types 2025-12-02 20:00:34 +03:00
Alex a94dfe0df4 Silent mode for errors of unsupported event types #15 2025-12-01 20:11:47 +03:00
Alex 03b1f158d9 Disabled api version #16 2025-11-30 17:10:00 +03:00
Alex d853faacf7 tag 1.3.2 2025-10-21 09:05:51 +03:00
Alex da7a07145b Fix send message response object 2025-10-20 21:27:54 +03:00
Alex 7cdbfc0f47 Update Message model 2025-10-08 23:14:06 +03:00
Alex f29344d2ec Update Message model 2025-10-07 23:56:57 +03:00
Alex 0dc10bd279 Fix authorization with header #10 2025-10-04 21:51:14 +03:00