mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 03:14:39 +01:00
add more updates
This commit is contained in:
parent
25471a3901
commit
d0dea06b39
46
src/EventHandler/BotCommands.php
Normal file
46
src/EventHandler/BotCommands.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @copyright 2016-2023 Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler;
|
||||
|
||||
use danog\MadelineProto\MTProto;
|
||||
|
||||
/**
|
||||
* The [command set](https://core.telegram.org/api/bots/commands) of a certain bot in a certain chat has changed.
|
||||
*/
|
||||
final class BotCommands extends Update
|
||||
{
|
||||
/** ID of the bot that changed its command set. */
|
||||
public readonly int $botId;
|
||||
|
||||
/** The affected chat. */
|
||||
public readonly int $chatId;
|
||||
|
||||
/** @var list<Command> New bot commands. */
|
||||
public readonly array $commands;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(MTProto $API, array $rawBotCommands)
|
||||
{
|
||||
parent::__construct($API);
|
||||
$this->botId = $rawBotCommands['bot_id'];
|
||||
$this->chatId = $API->getIdInternal($rawBotCommands['peer']);
|
||||
$this->commands = array_map(
|
||||
fn (array $command): Command => new Command($command),
|
||||
$rawBotCommands['commands']
|
||||
);
|
||||
}
|
||||
}
|
45
src/EventHandler/Channel/MessageForwards.php
Normal file
45
src/EventHandler/Channel/MessageForwards.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @copyright 2016-2023 Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler\Channel;
|
||||
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\EventHandler\Update;
|
||||
use danog\MadelineProto\MTProtoTools\DialogId;
|
||||
|
||||
/**
|
||||
* Represents the forward counter of a message in a channel has changed.
|
||||
*/
|
||||
final class MessageForwards extends Update
|
||||
{
|
||||
/** Channel ID */
|
||||
public readonly int $chatId;
|
||||
|
||||
/** ID of the message */
|
||||
public readonly int $id;
|
||||
|
||||
/** New forward counter */
|
||||
public readonly int $forwards;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(MTProto $API, array $rawMessageViews)
|
||||
{
|
||||
parent::__construct($API);
|
||||
$this->chatId = DialogId::fromSupergroupOrChannel($rawMessageViews['channel_id']);
|
||||
$this->id = $rawMessageViews['id'];
|
||||
$this->forwards = $rawMessageViews['forwards'];
|
||||
}
|
||||
}
|
51
src/EventHandler/Command.php
Normal file
51
src/EventHandler/Command.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Daniil Gentili <daniil@daniil.it>
|
||||
* @copyright 2016-2023 Daniil Gentili <daniil@daniil.it>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler;
|
||||
|
||||
use JsonSerializable;
|
||||
use ReflectionClass;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Represents a bot command that can be used in a chat.
|
||||
*/
|
||||
final class Command implements JsonSerializable
|
||||
{
|
||||
/** `/command` name. */
|
||||
public readonly string $command;
|
||||
|
||||
/** Description of the command. */
|
||||
public readonly string $description;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(array $rawCommand)
|
||||
{
|
||||
$this->command = $rawCommand['command'];
|
||||
$this->description = $rawCommand['description'];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$res = ['_' => static::class];
|
||||
$refl = new ReflectionClass($this);
|
||||
foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||
$res[$prop->getName()] = $prop->getValue($this);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
39
src/EventHandler/Pinned.php
Normal file
39
src/EventHandler/Pinned.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @copyright 2016-2023 Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler;
|
||||
|
||||
use danog\MadelineProto\MTProto;
|
||||
|
||||
/**
|
||||
* Represents messages s were pinned/unpinned.
|
||||
*/
|
||||
abstract class Pinned extends Update
|
||||
{
|
||||
/** Whether the messages were pinned or unpinned. */
|
||||
public readonly bool $pinned;
|
||||
|
||||
/** @var list<int> List of identifiers of pinned messages. */
|
||||
public readonly array $ids;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(MTProto $API, array $rawPinned)
|
||||
{
|
||||
parent::__construct($API);
|
||||
$this->pinned = $rawPinned['pinned'];
|
||||
$this->ids = $rawPinned['messages'];
|
||||
}
|
||||
}
|
37
src/EventHandler/Pinned/PinnedChannelMessages.php
Normal file
37
src/EventHandler/Pinned/PinnedChannelMessages.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @copyright 2016-2023 Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler\Pinned;
|
||||
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\EventHandler\Pinned;
|
||||
use danog\MadelineProto\MTProtoTools\DialogId;
|
||||
|
||||
/**
|
||||
* Represents messages s were pinned/unpinned in a [channel/supergroup](https://core.telegram.org/api/channel).
|
||||
*/
|
||||
final class PinnedChannelMessages extends Pinned
|
||||
{
|
||||
/** Channel ID. */
|
||||
public readonly int $chatId;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(MTProto $API, array $rawPinned)
|
||||
{
|
||||
parent::__construct($API, $rawPinned);
|
||||
$this->chatId = DialogId::fromSupergroupOrChannel($rawPinned['channel_id']);
|
||||
}
|
||||
}
|
37
src/EventHandler/Pinned/PinnedMessages.php
Normal file
37
src/EventHandler/Pinned/PinnedMessages.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of MadelineProto.
|
||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Affero General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @copyright 2016-2023 Amir Hossein Jafari <amirhosseinjafari8228@gmail.com>
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\EventHandler\Pinned;
|
||||
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\EventHandler\Pinned;
|
||||
use danog\MadelineProto\MTProtoTools\DialogId;
|
||||
|
||||
/**
|
||||
* Some messages were pinned in a chat.
|
||||
*/
|
||||
final class PinnedMessages extends Pinned
|
||||
{
|
||||
/** Peer ID. */
|
||||
public readonly int $chatId;
|
||||
|
||||
/** @internal */
|
||||
public function __construct(MTProto $API, array $rawPinned)
|
||||
{
|
||||
parent::__construct($API, $rawPinned);
|
||||
$this->chatId = $API->getIdInternal($rawPinned['peer']);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user