Added MessageCallbackUpdate & MessageEditedUpdate & MessageRemovedUpdate & BotAddedToChatUpdate

This commit is contained in:
Alex
2025-07-24 09:11:01 +03:00
parent 62c4b80fae
commit d5b950bcd9
14 changed files with 503 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Models;
/**
* Object sent to bot when user presses a callback button.
*/
final readonly class Callback extends AbstractModel
{
/**
* @param int $timestamp Unix-time when user pressed the button.
* @param string $callbackId Identifier of the callback, unique for the message.
* @param string $payload Payload from the pressed button.
* @param User $user User who pressed the button.
*/
public function __construct(
public int $timestamp,
public string $callbackId,
public string $payload,
public User $user,
) {
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Models\Updates;
use BushlanovDev\MaxMessengerBot\Enums\UpdateType;
use BushlanovDev\MaxMessengerBot\Models\User;
/**
* You will receive this update when the bot has been added to a chat.
*/
final readonly class BotAddedToChatUpdate extends AbstractUpdate
{
/**
* @param int $timestamp Unix-time when the event has occurred.
* @param int $chatId Chat ID where the bot was added.
* @param User $user User who added the bot to the chat.
* @param bool $isChannel Indicates whether the bot has been added to a channel or not.
*/
public function __construct(
int $timestamp,
public int $chatId,
public User $user,
public bool $isChannel,
) {
parent::__construct(UpdateType::BotAdded, $timestamp);
}
}
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Models\Updates;
use BushlanovDev\MaxMessengerBot\Enums\UpdateType;
use BushlanovDev\MaxMessengerBot\Models\Callback;
use BushlanovDev\MaxMessengerBot\Models\Message;
/**
* You will get this update as soon as a user presses a callback button.
*/
final readonly class MessageCallbackUpdate extends AbstractUpdate
{
/**
* @param int $timestamp Unix-time when event has occurred.
* @param Callback $callback The callback query itself.
* @param Message|null $message Original message with the inline keyboard. Can be null if the message was deleted.
* @param string|null $userLocale Current user locale in IETF BCP 47 format.
*/
public function __construct(
int $timestamp,
public Callback $callback,
public ?Message $message,
public ?string $userLocale,
) {
parent::__construct(UpdateType::MessageCallback, $timestamp);
}
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Models\Updates;
use BushlanovDev\MaxMessengerBot\Enums\UpdateType;
use BushlanovDev\MaxMessengerBot\Models\Message;
/**
* You will get this update as soon as a message is edited.
*/
final readonly class MessageEditedUpdate extends AbstractUpdate
{
/**
* @param int $timestamp Unix-time when the event has occurred.
* @param Message $message The edited message.
*/
public function __construct(
int $timestamp,
public Message $message,
) {
parent::__construct(UpdateType::MessageEdited, $timestamp);
}
}
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Models\Updates;
use BushlanovDev\MaxMessengerBot\Enums\UpdateType;
/**
* You will get this update as soon as a message is removed.
*/
final readonly class MessageRemovedUpdate extends AbstractUpdate
{
/**
* @param int $timestamp Unix-time when the event has occurred.
* @param string $messageId Identifier of the removed message.
* @param int $chatId Chat identifier where the message has been deleted.
* @param int $userId User who deleted this message.
*/
public function __construct(
int $timestamp,
public string $messageId,
public int $chatId,
public int $userId,
) {
parent::__construct(UpdateType::MessageRemoved, $timestamp);
}
}