1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 09:58:59 +01:00

add more updates

This commit is contained in:
َAhJ 2023-10-13 15:54:44 +03:30
parent 25471a3901
commit d0dea06b39
6 changed files with 255 additions and 0 deletions

View 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']
);
}
}

View 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'];
}
}

View 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;
}
}

View 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'];
}
}

View 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']);
}
}

View 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']);
}
}