mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:59:02 +01:00
add getStory method, fix doctypes
This commit is contained in:
parent
7f784c66f0
commit
bdb1918bc5
@ -19,6 +19,8 @@ namespace danog\MadelineProto\EventHandler;
|
||||
use AssertionError;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\ParseMode;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Webmozart\Assert\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Represents an incoming or outgoing message.
|
||||
@ -228,9 +230,11 @@ abstract class AbstractMessage extends Update implements SimpleFilters
|
||||
*
|
||||
* @param boolean $stories
|
||||
* @return boolean
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function block(bool $stories): bool
|
||||
{
|
||||
Assert::false(MTProto::isSupergroupOrChannel($this->senderId));
|
||||
return $this->getClient()->methodCallAsyncRead(
|
||||
'contacts.block',
|
||||
[
|
||||
@ -245,9 +249,11 @@ abstract class AbstractMessage extends Update implements SimpleFilters
|
||||
*
|
||||
* @param boolean $stories
|
||||
* @return boolean
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function unblock(bool $stories): bool
|
||||
{
|
||||
Assert::false(MTProto::isSupergroupOrChannel($this->senderId));
|
||||
return $this->getClient()->methodCallAsyncRead(
|
||||
'contacts.block',
|
||||
[
|
||||
@ -256,4 +262,34 @@ abstract class AbstractMessage extends Update implements SimpleFilters
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user stories
|
||||
*
|
||||
* @return list<AbstractStory>
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getStory(): array
|
||||
{
|
||||
Assert::false(MTProto::isSupergroupOrChannel($this->senderId));
|
||||
$client = $this->getClient();
|
||||
$result = $client->methodCallAsyncRead(
|
||||
'stories.getUserStories',
|
||||
[
|
||||
'user_id' => $this->senderId,
|
||||
]
|
||||
)['stories']['stories'];
|
||||
$result = array_filter($result, fn (array $t): bool => $t['_'] !== 'storyItemDeleted');
|
||||
$result = $client->methodCallAsyncRead(
|
||||
'stories.getStoriesByID',
|
||||
[
|
||||
'user_id' => $this->senderId,
|
||||
'id' => array_column($result, 'id'),
|
||||
]
|
||||
)['stories'];
|
||||
return array_map(
|
||||
$client->wrapUpdate(...),
|
||||
$result
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ use danog\MadelineProto\EventHandler\Participant\Creator;
|
||||
use danog\MadelineProto\EventHandler\Participant\Left;
|
||||
use danog\MadelineProto\EventHandler\Participant\Member;
|
||||
use danog\MadelineProto\EventHandler\Participant\MySelf;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Webmozart\Assert\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Represents an incoming or outgoing group message.
|
||||
@ -165,4 +168,23 @@ final class GroupMessage extends Message
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a basic group into a supergroup
|
||||
*
|
||||
* @return integer the channel id that migrate to
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function toSuperGroup(): int
|
||||
{
|
||||
Assert::false(MTProto::isSupergroupOrChannel($this->chatId));
|
||||
$client = $this->getClient();
|
||||
$result = $client->methodCallAsyncRead(
|
||||
'messages.migrateChat',
|
||||
[
|
||||
'chat_id' => $this->chatId
|
||||
]
|
||||
);
|
||||
return $client->toSuperGroup($result['updates'][0]['channel_id']);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ final class PrivateMessage extends Message
|
||||
/**
|
||||
* Notify the other user in a private chat that a screenshot of the chat was taken.
|
||||
*
|
||||
* @return DialogScreenshotTaken
|
||||
*/
|
||||
public function screenShot(): DialogScreenshotTaken
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user