1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 04:14:57 +01:00

Rename some classes before release

This commit is contained in:
Daniil Gentili 2023-09-06 19:33:52 +02:00
parent aa6bccd456
commit 41de551a96
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
46 changed files with 129 additions and 119 deletions

2
docs

@ -1 +1 @@
Subproject commit 1af0095472c40f98ae4bdd4af7d741ce36839eaf Subproject commit 355943bfe72fac6b1e42301a5c1db6f5a1029841

View File

@ -407,11 +407,6 @@
<code>new $class</code> <code>new $class</code>
</UnsafeInstantiation> </UnsafeInstantiation>
</file> </file>
<file src="src/EventHandler/AbstractAction.php">
<UnhandledMatchCondition>
<code>$type</code>
</UnhandledMatchCondition>
</file>
<file src="src/EventHandler/AbstractMessage.php"> <file src="src/EventHandler/AbstractMessage.php">
<InvalidReturnStatement> <InvalidReturnStatement>
<code><![CDATA[$this->replyCache]]></code> <code><![CDATA[$this->replyCache]]></code>
@ -438,6 +433,11 @@
<code><![CDATA[$client->wrapMessage($client->extractMessage($result))]]></code> <code><![CDATA[$client->wrapMessage($client->extractMessage($result))]]></code>
</NullableReturnStatement> </NullableReturnStatement>
</file> </file>
<file src="src/EventHandler/Action.php">
<UnhandledMatchCondition>
<code>$type</code>
</UnhandledMatchCondition>
</file>
<file src="src/EventHandler/Filter/AbstractFilterFromSender.php"> <file src="src/EventHandler/Filter/AbstractFilterFromSender.php">
<PropertyNotSetInConstructor> <PropertyNotSetInConstructor>
<code>$peerResolved</code> <code>$peerResolved</code>
@ -663,6 +663,11 @@
<code><![CDATA[$API->getIdInternal($rawParticipant['peer'])]]></code> <code><![CDATA[$API->getIdInternal($rawParticipant['peer'])]]></code>
</PossiblyNullPropertyAssignmentValue> </PossiblyNullPropertyAssignmentValue>
</file> </file>
<file src="src/EventHandler/Privacy.php">
<PropertyTypeCoercion>
<code><![CDATA[\array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules'])]]></code>
</PropertyTypeCoercion>
</file>
<file src="src/EventHandler/Query/ChatTrait.php"> <file src="src/EventHandler/Query/ChatTrait.php">
<MoreSpecificReturnType> <MoreSpecificReturnType>
<code>Message</code> <code>Message</code>
@ -698,7 +703,7 @@
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
<PropertyTypeCoercion> <PropertyTypeCoercion>
<code><![CDATA[$API->wrapMedia($rawStory['media'], $this->protected)]]></code> <code><![CDATA[$API->wrapMedia($rawStory['media'], $this->protected)]]></code>
<code><![CDATA[\array_map(AbstractRule::fromRawRule(...), $rawStory['privacy'] ?? [])]]></code> <code><![CDATA[\array_map(RuleDestination::fromRawRule(...), $rawStory['privacy'] ?? [])]]></code>
</PropertyTypeCoercion> </PropertyTypeCoercion>
</file> </file>
<file src="src/EventHandler/User/Blocked.php"> <file src="src/EventHandler/User/Blocked.php">

View File

@ -51,7 +51,7 @@ final class API extends AbstractAPI
* *
* @var string * @var string
*/ */
public const RELEASE = '8.0.0-beta144'; public const RELEASE = '8.0.0-beta145';
/** /**
* Secret chat was not found. * Secret chat was not found.
* *

View File

@ -550,7 +550,7 @@ final class Blacklist {
$had = []; $had = [];
foreach (ClassFinder::getClassesInNamespace(\danog\MadelineProto\EventHandler::class, ClassFinder::RECURSIVE_MODE) as $class) { foreach (ClassFinder::getClassesInNamespace(\danog\MadelineProto\EventHandler::class, ClassFinder::RECURSIVE_MODE) as $class) {
$name = \basename(\str_replace('\\', '//', $class)); $name = \basename(\str_replace('\\', '//', $class));
if (isset($had[$name]) || $name === 'Status') { if (isset($had[$name]) || $name === 'Status' || $name === 'Action') {
continue; continue;
} }
$had[$name] = true; $had[$name] = true;

View File

@ -305,7 +305,7 @@ abstract class AbstractMessage extends Update implements SimpleFilters
* *
* @return boolean * @return boolean
*/ */
public function setAction(AbstractAction $action = new Typing): bool public function setAction(Action $action = new Typing): bool
{ {
$action = $action->toRawAction() + [ 'msg_id' => $this->id ]; $action = $action->toRawAction() + [ 'msg_id' => $this->id ];
return $this->getClient()->methodCallAsyncRead( return $this->getClient()->methodCallAsyncRead(

View File

@ -38,11 +38,12 @@ use ReflectionClass;
use ReflectionProperty; use ReflectionProperty;
/** /**
* Typing events. * In-progress actions.
*/ */
abstract class AbstractAction implements JsonSerializable abstract class Action implements JsonSerializable
{ {
public static function fromRawAction(array $rawAction): AbstractAction /** @internal */
public static function fromRawAction(array $rawAction): Action
{ {
$type = $rawAction['_']; $type = $rawAction['_'];
if ($type === 'sendMessageEmojiInteraction') { if ($type === 'sendMessageEmojiInteraction') {
@ -73,6 +74,7 @@ abstract class AbstractAction implements JsonSerializable
}; };
} }
/** @internal */
public function toRawAction(): array public function toRawAction(): array
{ {
return match (true) { return match (true) {

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* Invalidate all previous action updates. E.g. when user deletes entered text or aborts a video upload. * Invalidate all previous action updates. E.g. when user deletes entered text or aborts a video upload.
*/ */
final class Cancel extends AbstractAction final class Cancel extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is selecting a contact to share. * User is selecting a contact to share.
*/ */
final class ChooseContact extends AbstractAction final class ChooseContact extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is choosing a sticker. * User is choosing a sticker.
*/ */
final class ChooseSticker extends AbstractAction final class ChooseSticker extends Action
{ {
} }

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is watching an animated emoji reaction triggered by another user, [click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions). * User is watching an animated emoji reaction triggered by another user, [click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions).
*/ */
final class EmojiSeen extends AbstractAction final class EmojiSeen extends Action
{ {
public function __construct( public function __construct(
/** @var string Emoji */ /** @var string Emoji */

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User has clicked on an animated emoji triggering a [reaction, click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions). * User has clicked on an animated emoji triggering a [reaction, click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions).
*/ */
final class EmojiTap extends AbstractAction final class EmojiTap extends Action
{ {
public function __construct( public function __construct(
/** @var string Emoji */ /** @var string Emoji */

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is playing a game. * User is playing a game.
*/ */
final class GamePlay extends AbstractAction final class GamePlay extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is selecting a location to share. * User is selecting a location to share.
*/ */
final class GeoLocation extends AbstractAction final class GeoLocation extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is currently speaking in the group call. * User is currently speaking in the group call.
*/ */
final class GroupCallSpeaking extends AbstractAction final class GroupCallSpeaking extends Action
{ {
} }

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* Chat history is being imported. * Chat history is being imported.
*/ */
final class HistoryImport extends AbstractAction final class HistoryImport extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is recording a voice message. * User is recording a voice message.
*/ */
final class RecordAudio extends AbstractAction final class RecordAudio extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is recording a round video to share. * User is recording a round video to share.
*/ */
final class RecordRound extends AbstractAction final class RecordRound extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is recording a video. * User is recording a video.
*/ */
final class RecordVideo extends AbstractAction final class RecordVideo extends Action
{ {
} }

View File

@ -16,11 +16,11 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is typing. * User is typing.
*/ */
final class Typing extends AbstractAction final class Typing extends Action
{ {
} }

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is uploading a voice message. * User is uploading a voice message.
*/ */
final class UploadAudio extends AbstractAction final class UploadAudio extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is uploading a file. * User is uploading a file.
*/ */
final class UploadDocument extends AbstractAction final class UploadDocument extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is uploading a photo. * User is uploading a photo.
*/ */
final class UploadPhoto extends AbstractAction final class UploadPhoto extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is uploading a round video. * User is uploading a round video.
*/ */
final class UploadRound extends AbstractAction final class UploadRound extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -16,12 +16,12 @@
namespace danog\MadelineProto\EventHandler\Action; namespace danog\MadelineProto\EventHandler\Action;
use danog\MadelineProto\EventHandler\AbstractAction; use danog\MadelineProto\EventHandler\Action;
/** /**
* User is uploading a video. * User is uploading a video.
*/ */
final class UploadVideo extends AbstractAction final class UploadVideo extends Action
{ {
public function __construct( public function __construct(
/** @var ?int Progress percentage */ /** @var ?int Progress percentage */

View File

@ -22,7 +22,7 @@ use danog\MadelineProto\MTProto;
/** /**
* Represents a service message about a group call. * Represents a service message about a group call.
*/ */
abstract class AbstractDialogGroupCall extends ServiceMessage abstract class DialogGroupCall extends ServiceMessage
{ {
/** Group call ID */ /** Group call ID */
public readonly int $callId; public readonly int $callId;

View File

@ -16,13 +16,13 @@
namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
* The group call has started or ended. * The group call has started or ended.
*/ */
final class GroupCall extends AbstractDialogGroupCall final class GroupCall extends DialogGroupCall
{ {
/** @var bool Whether that group call ended or not. */ /** @var bool Whether that group call ended or not. */
public readonly bool $ended; public readonly bool $ended;

View File

@ -16,13 +16,13 @@
namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
* A set of users was invited to the group call. * A set of users was invited to the group call.
*/ */
final class GroupCallInvited extends AbstractDialogGroupCall final class GroupCallInvited extends DialogGroupCall
{ {
public function __construct( public function __construct(
MTProto $API, MTProto $API,

View File

@ -16,13 +16,13 @@
namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
* A group call was scheduled. * A group call was scheduled.
*/ */
final class GroupCallScheduled extends AbstractDialogGroupCall final class GroupCallScheduled extends DialogGroupCall
{ {
public function __construct( public function __construct(
MTProto $API, MTProto $API,

View File

@ -16,8 +16,8 @@
namespace danog\MadelineProto\EventHandler; namespace danog\MadelineProto\EventHandler;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\Rule;
use danog\MadelineProto\EventHandler\Privacy\Key; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
@ -26,16 +26,16 @@ use danog\MadelineProto\MTProto;
final class Privacy extends Update final class Privacy extends Update
{ {
/** New privacy rule. */ /** New privacy rule. */
public readonly Key $key; public readonly Rule $rule;
/** Peers to which the privacy rules apply */ /** @var list<RuleDestination> Peers to which the privacy rules apply */
public readonly array $rules; public readonly array $appliesTo;
/** @internal */ /** @internal */
public function __construct(MTProto $API, array $rawPrivacy) public function __construct(MTProto $API, array $rawPrivacy)
{ {
parent::__construct($API); parent::__construct($API);
$this->key = Key::fromRawKey($rawPrivacy['key']['_']); $this->rule = Rule::fromRawKey($rawPrivacy['key']['_']);
$this->rules = \array_map(AbstractRule::fromRawRule(...), $rawPrivacy['rules']); $this->appliesTo = \array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules']);
} }
} }

View File

@ -19,7 +19,8 @@ namespace danog\MadelineProto\EventHandler\Privacy;
use AssertionError; use AssertionError;
use JsonSerializable; use JsonSerializable;
enum Key: string implements JsonSerializable /** Represents a privacy rule. */
enum Rule: string implements JsonSerializable
{ {
/** Whether we can see the last online timestamp of this user */ /** Whether we can see the last online timestamp of this user */
case STATUS_TIMESTAMP = 'privacyKeyStatusTimestamp'; case STATUS_TIMESTAMP = 'privacyKeyStatusTimestamp';
@ -39,17 +40,17 @@ enum Key: string implements JsonSerializable
case ADDED_BY_PHONE = 'privacyKeyAddedByPhone'; case ADDED_BY_PHONE = 'privacyKeyAddedByPhone';
/** Whether the user accepts voice messages */ /** Whether the user accepts voice messages */
case VOICE_MESSAGES = 'privacyKeyVoiceMessages'; case VOICE_MESSAGES = 'privacyKeyVoiceMessages';
/** Whether the user can see our bio. */
case ABOUT = 'privacyKeyAbout'; case ABOUT = 'privacyKeyAbout';
/** /**
* * @internal
* *
* @throws AssertionError * @throws AssertionError
*/ */
public static function fromRawKey(string $key): Key public static function fromRawKey(string $key): Rule
{ {
foreach (Key::cases() as $case) { foreach (Rule::cases() as $case) {
if ($case->value === $key) { if ($case->value === $key) {
return $case; return $case;
} }

View File

@ -16,22 +16,25 @@
namespace danog\MadelineProto\EventHandler\Privacy; namespace danog\MadelineProto\EventHandler\Privacy;
use danog\MadelineProto\EventHandler\Privacy\Rule\AllowAll; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowAll;
use danog\MadelineProto\EventHandler\Privacy\Rule\AllowChatParticipants; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowChatParticipants;
use danog\MadelineProto\EventHandler\Privacy\Rule\AllowCloseFriends; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowCloseFriends;
use danog\MadelineProto\EventHandler\Privacy\Rule\AllowContacts; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowContacts;
use danog\MadelineProto\EventHandler\Privacy\Rule\AllowUsers; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowUsers;
use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowAll; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowAll;
use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowChatParticipants; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowChatParticipants;
use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowContacts; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowContacts;
use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowUsers; use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowUsers;
use JsonSerializable; use JsonSerializable;
use ReflectionClass; use ReflectionClass;
use ReflectionProperty; use ReflectionProperty;
abstract class AbstractRule implements JsonSerializable /**
* To whom does a privacy rule apply?
*/
abstract class RuleDestination implements JsonSerializable
{ {
public static function fromRawRule(array $rawRule): AbstractRule public static function fromRawRule(array $rawRule): RuleDestination
{ {
return match ($rawRule['_']) { return match ($rawRule['_']) {
'privacyValueAllowAll' => new AllowAll, 'privacyValueAllowAll' => new AllowAll,

View File

@ -14,13 +14,13 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Allow all users. * Allow all users.
*/ */
final class AllowAll extends AbstractRule final class AllowAll extends RuleDestination
{ {
} }

View File

@ -14,14 +14,14 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Allow all participants of certain chats. * Allow all participants of certain chats.
*/ */
final class AllowChatParticipants extends AbstractRule final class AllowChatParticipants extends RuleDestination
{ {
/** Allowed chats */ /** Allowed chats */
public readonly array $chats; public readonly array $chats;

View File

@ -14,10 +14,10 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
final class AllowCloseFriends extends AbstractRule final class AllowCloseFriends extends RuleDestination
{ {
} }

View File

@ -14,13 +14,13 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Allow all contacts. * Allow all contacts.
*/ */
final class AllowContacts extends AbstractRule final class AllowContacts extends RuleDestination
{ {
} }

View File

@ -14,14 +14,14 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Allow only certain user. * Allow only certain user.
*/ */
final class AllowUsers extends AbstractRule final class AllowUsers extends RuleDestination
{ {
/** Allowed users */ /** Allowed users */
public readonly array $users; public readonly array $users;

View File

@ -14,13 +14,13 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Disallow all users. * Disallow all users.
*/ */
final class DisallowAll extends AbstractRule final class DisallowAll extends RuleDestination
{ {
} }

View File

@ -14,14 +14,14 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Disallow only participants of certain chats. * Disallow only participants of certain chats.
*/ */
final class DisallowChatParticipants extends AbstractRule final class DisallowChatParticipants extends RuleDestination
{ {
/** Allowed chats */ /** Allowed chats */
public readonly array $chats; public readonly array $chats;

View File

@ -14,13 +14,13 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Disallow only contacts. * Disallow only contacts.
*/ */
final class DisallowContacts extends AbstractRule final class DisallowContacts extends RuleDestination
{ {
} }

View File

@ -14,14 +14,14 @@
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\EventHandler\Privacy\Rule; namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
/** /**
* Disallow only certain users. * Disallow only certain users.
*/ */
final class DisallowUsers extends AbstractRule final class DisallowUsers extends RuleDestination
{ {
/** Allowed users */ /** Allowed users */
public readonly array $users; public readonly array $users;

View File

@ -24,7 +24,7 @@ use danog\MadelineProto\EventHandler\Media\Video;
use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity; use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity;
use danog\MadelineProto\EventHandler\Message\ReportReason; use danog\MadelineProto\EventHandler\Message\ReportReason;
use danog\MadelineProto\EventHandler\Privacy\AbstractRule; use danog\MadelineProto\EventHandler\Privacy\RuleDestination;
use danog\MadelineProto\Ipc\Client; use danog\MadelineProto\Ipc\Client;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
use danog\MadelineProto\ParseMode; use danog\MadelineProto\ParseMode;
@ -74,7 +74,7 @@ final class Story extends AbstractStory
/** A set of physical coordinates associated to this story */ /** A set of physical coordinates associated to this story */
//public readonly ?array $mediaAreas; //! //public readonly ?array $mediaAreas; //!
/** @var list<AbstractRule> */ /** @var list<RuleDestination> */
public readonly array $privacy; public readonly array $privacy;
/** Our reaction to the story */ /** Our reaction to the story */
@ -113,7 +113,7 @@ final class Story extends AbstractStory
$this->media = $API->wrapMedia($rawStory['media'], $this->protected); $this->media = $API->wrapMedia($rawStory['media'], $this->protected);
$this->entities = MessageEntity::fromRawEntities($rawStory['entities'] ?? []); $this->entities = MessageEntity::fromRawEntities($rawStory['entities'] ?? []);
$this->privacy = \array_map(AbstractRule::fromRawRule(...), $rawStory['privacy'] ?? []); $this->privacy = \array_map(RuleDestination::fromRawRule(...), $rawStory['privacy'] ?? []);
$this->recentViewers = $rawStory['views']['recent_viewers'] ?? []; $this->recentViewers = $rawStory['views']['recent_viewers'] ?? [];
$this->views = $rawStory['views']['views_count'] ?? null; $this->views = $rawStory['views']['views_count'] ?? null;

View File

@ -21,19 +21,19 @@ use danog\MadelineProto\MTProto;
/** /**
* A user is typing. * A user is typing.
*/ */
abstract class AbstractTyping extends Update abstract class Typing extends Update
{ {
/** @var int The user id that is typing. */ /** @var int The user id that is typing. */
public readonly int $userId; public readonly int $userId;
/** @var AbstractAction Whether the user is typing, sending a media or doing something else. */ /** @var Action Whether the user is typing, sending a media or doing something else. */
public readonly AbstractAction $action; public readonly Action $action;
/** @internal */ /** @internal */
public function __construct(MTProto $API, array $rawTyping) public function __construct(MTProto $API, array $rawTyping)
{ {
parent::__construct($API); parent::__construct($API);
$this->userId = $rawTyping['user_id'] ?? $API->getIdInternal($rawTyping['from_id']); $this->userId = $rawTyping['user_id'] ?? $API->getIdInternal($rawTyping['from_id']);
$this->action = AbstractAction::fromRawAction($rawTyping['action']); $this->action = Action::fromRawAction($rawTyping['action']);
} }
} }

View File

@ -16,14 +16,14 @@
namespace danog\MadelineProto\EventHandler\Typing; namespace danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\EventHandler\AbstractTyping; use danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
use danog\MadelineProto\MTProtoTools\DialogId; use danog\MadelineProto\MTProtoTools\DialogId;
/** /**
* A user is typing in a [supergroup](https://core.telegram.org/api/channel). * A user is typing in a [supergroup](https://core.telegram.org/api/channel).
*/ */
final class SupergroupUserTyping extends AbstractTyping final class SupergroupUserTyping extends Typing
{ {
/** @var int Channel ID. */ /** @var int Channel ID. */
public readonly int $chatId; public readonly int $chatId;

View File

@ -16,13 +16,13 @@
namespace danog\MadelineProto\EventHandler\Typing; namespace danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\EventHandler\AbstractTyping; use danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
* The user is preparing a message; typing, recording, uploading, etc. This update is valid for 6 seconds. If no further updates of this kind are received after 6 seconds, it should be considered that the user stopped doing whatever they were doing. * The user is preparing a message; typing, recording, uploading, etc. This update is valid for 6 seconds. If no further updates of this kind are received after 6 seconds, it should be considered that the user stopped doing whatever they were doing.
*/ */
final class UserTyping extends AbstractTyping final class UserTyping extends Typing
{ {
/** @internal */ /** @internal */
public function __construct(MTProto $API, array $rawTyping) public function __construct(MTProto $API, array $rawTyping)

View File

@ -20,7 +20,7 @@ use danog\MadelineProto\EventHandler\User\Status;
use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProto;
/** /**
* The [emoji status](https://core.telegram.org/api/emoji-status) of a certain user has changed or removed. * The [emoji status](https://core.telegram.org/api/emoji-status) of a certain user has changed or was removed.
*/ */
final class Emoji extends Status final class Emoji extends Status
{ {

View File

@ -37,7 +37,6 @@ use danog\MadelineProto\EventHandler\Message\Entities\Spoiler;
use danog\MadelineProto\EventHandler\Message\Entities\Url; use danog\MadelineProto\EventHandler\Message\Entities\Url;
use danog\MadelineProto\EventHandler\Participant\Admin; use danog\MadelineProto\EventHandler\Participant\Admin;
use danog\MadelineProto\EventHandler\Participant\Member; use danog\MadelineProto\EventHandler\Participant\Member;
use danog\MadelineProto\EventHandler\Privacy\Key;
use danog\MadelineProto\EventHandler\Update; use danog\MadelineProto\EventHandler\Update;
use danog\MadelineProto\EventHandler\User\Status\Emoji; use danog\MadelineProto\EventHandler\User\Status\Emoji;
use danog\MadelineProto\EventHandler\User\Username; use danog\MadelineProto\EventHandler\User\Username;