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

Convert InlineQueryPeerType to enum

This commit is contained in:
َAhJ 2023-08-29 11:42:16 +03:30
parent 23de98b326
commit 94cc11410f
7 changed files with 30 additions and 66 deletions

View File

@ -2,13 +2,37 @@
namespace danog\MadelineProto\EventHandler;
use JsonSerializable;
abstract class InlineQueryPeerType implements JsonSerializable
/**
* Inline query peer type
*/
enum InlineQueryPeerType
{
/** @internal */
public function jsonSerialize(): mixed
/** private chat */
case InlineQueryPeerTypePM;
/** [chat](https://core.telegram.org/api/channel) */
case InlineQueryPeerTypeChat;
/** private chat with a bot. */
case InlineQueryPeerTypeBotPM;
/** [channel](https://core.telegram.org/api/channel) */
case InlineQueryPeerTypeBroadcast;
/** [supergroup](https://core.telegram.org/api/channel) */
case InlineQueryPeerTypeMegagroup;
/** private chat with the bot itself */
case InlineQueryPeerTypeSameBotPM;
/**
* Get InlineQueryPeerType from update
*
* @param string Type of the chat from which the inline query was sent.
*/
public static function fromString(string $name): ?InlineQueryPeerType
{
return ['_' => static::class];
$name = ucfirst($name);
foreach(InlineQueryPeerType::cases() as $status)
{
if($status->name === $name)
return $status;
}
return null;
}
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypeBotPM extends InlineQueryPeerType
{
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypeBroadcast extends InlineQueryPeerType
{
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypeChat extends InlineQueryPeerType
{
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypeMegagroup extends InlineQueryPeerType
{
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypePM extends InlineQueryPeerType
{
}

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler\InlineQueryPeerType;
use danog\MadelineProto\EventHandler\InlineQueryPeerType;
class InlineQueryPeerTypeSameBotPM extends InlineQueryPeerType
{
}