mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 01:34:40 +01:00
Delete replyInlineBotResult as incomplete!
- also add 3 methods delReaction addReaction and getReactions
This commit is contained in:
parent
de625e5311
commit
bdd0baac59
@ -210,47 +210,4 @@ abstract class AbstractMessage extends Update implements SimpleFilters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply inlineBotResult to message
|
||||
*
|
||||
* @param BigInteger $queryId Query ID from <a href='https://docs.madelineproto.xyz/API_docs/methods/messages.getInlineBotResults.html'>messages.getInlineBotResults</a>
|
||||
* @param int $id Result ID from <a href='https://docs.madelineproto.xyz/API_docs/methods/messages.getInlineBotResults.html'>messages.getInlineBotResults</a>
|
||||
* @param array|null $replyTo reply to specific message
|
||||
* @param int|string|null $sendAs Send this message as the specified peer
|
||||
* @param int|null $scheduleDate Schedule date.
|
||||
* @param bool $hideVia Whether to hide the via @botname in the resulting message (only for bot usernames encountered in the <a href='https://docs.madelineproto.xyz/API_docs/constructors/config.html'>config</a>)
|
||||
* @param bool $clearDraft Clears the draft field
|
||||
* @param bool $silent Whether to send the message silently, without triggering notifications.
|
||||
* @param bool $background Send this message as background message
|
||||
* @return Update|null Return Update or null
|
||||
*
|
||||
*/
|
||||
public function replyInlineBotResult(
|
||||
BigInteger $queryId,
|
||||
int $id,
|
||||
?array $replyTo = null,
|
||||
int|string|null $sendAs = null,
|
||||
?int $scheduleDate = null,
|
||||
bool $hideVia = false,
|
||||
bool $clearDraft = false,
|
||||
bool $silent = false,
|
||||
bool $background = false
|
||||
): ?Update
|
||||
{
|
||||
return $this->API->wrapUpdate($this->API->methodCallAsyncRead(
|
||||
'messages.sendInlineBotResult',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'reply_to' => $replyTo ?? ['_' => 'inputReplyToMessage', 'reply_to_msg_id' => $this->id, 'top_msg_id' => $this->topicId === 1 ? null : $this->topicId],
|
||||
'query_id' => $queryId,
|
||||
'id' => $id,
|
||||
'send_as' => $sendAs,
|
||||
'schedule_date' => $scheduleDate,
|
||||
'hide_via' => $hideVia,
|
||||
'clear_draft' => $clearDraft,
|
||||
'silent' => $silent,
|
||||
'background' => $background
|
||||
]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,12 @@ abstract class Message extends AbstractMessage
|
||||
/** Content of the message */
|
||||
public readonly string $message;
|
||||
|
||||
private bool $reactionsCached = false;
|
||||
|
||||
|
||||
/** @var list<int|string> list of our message reactions */
|
||||
private ?array $reactions;
|
||||
|
||||
/** Info about a forwarded message */
|
||||
public readonly ?ForwardedInfo $fwdInfo;
|
||||
|
||||
@ -146,7 +152,7 @@ abstract class Message extends AbstractMessage
|
||||
*/
|
||||
public function pin(bool $pmOneside = false,bool $silent = false) : ?AbstractMessage
|
||||
{
|
||||
$result = $this->API->methodCallAsyncRead(
|
||||
$result = $this->getClient()->methodCallAsyncRead(
|
||||
'messages.updatePinnedMessage',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
@ -156,7 +162,7 @@ abstract class Message extends AbstractMessage
|
||||
'unpin' => false
|
||||
]
|
||||
);
|
||||
return $this->API->wrapMessage($this->API->extractMessage($result));
|
||||
return $this->getClient()->wrapMessage($this->getClient()->extractMessage($result));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +174,7 @@ abstract class Message extends AbstractMessage
|
||||
*/
|
||||
public function unpin(bool $pmOneside = false,bool $silent = false) : ?Update
|
||||
{
|
||||
$result = $this->API->methodCallAsyncRead(
|
||||
$result = $this->getClient()->methodCallAsyncRead(
|
||||
'messages.updatePinnedMessage',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
@ -178,9 +184,76 @@ abstract class Message extends AbstractMessage
|
||||
'unpin' => true
|
||||
]
|
||||
);
|
||||
return $this->API->wrapUpdate($result);
|
||||
return $this->getClient()->wrapUpdate($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our reaction on message return null if message deleted
|
||||
*
|
||||
* @return list<string|int>|null
|
||||
*/
|
||||
public function getReactions(): ?array
|
||||
{
|
||||
if(!$this->reactionsCached){
|
||||
$this->reactionsCached = true;
|
||||
$me = $this->getClient()->getSelf()['id'];
|
||||
$myReactions = array_filter(
|
||||
$this->getClient()->methodCallAsyncRead(
|
||||
'messages.getMessageReactionsList',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'id' => $this->id
|
||||
]
|
||||
)['reactions'],
|
||||
fn($reactions):bool => $reactions['peer_id']['user_id'] ?? $reactions['peer_id']['channel_id'] == $me
|
||||
);
|
||||
$this->reactions = array_map(fn($reaction) => $reaction['reaction']['emoticon'] ?? $reaction['reaction']['document_id'] ,$myReactions);
|
||||
}
|
||||
return $this->reactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add reaction to message
|
||||
*
|
||||
* @param list<string|int> $reaction Array of Reaction
|
||||
* @param bool $big Whether a bigger and longer reaction should be shown
|
||||
* @param bool $addToRecent Add this reaction to the recent reactions list.
|
||||
* @return Update|null
|
||||
*/
|
||||
public function addReaction(array $reaction,bool $big = false,bool $addToRecent = true) :?Update{
|
||||
$result = $this->getClient()->methodCallAsyncRead(
|
||||
'messages.sendReaction',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'msg_id' => $this->id,
|
||||
'reaction' => array_map(fn($reactions) => is_int($reactions) ? ['_' => 'reactionCustomEmoji', 'document_id' => $reactions] : ['_' => 'reactionEmoji', 'emoticon' => $reactions],$reaction),
|
||||
'big' => $big,
|
||||
'add_to_recent' => $addToRecent
|
||||
]
|
||||
);
|
||||
$this->reactions += $reaction;
|
||||
return $this->getClient()->wrapUpdate($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete reaction from message
|
||||
*
|
||||
* @param string|int $reaction string or int Reaction
|
||||
* @return Update|null
|
||||
*/
|
||||
public function delReaction(int|string $reaction): ?Update
|
||||
{
|
||||
$result = $this->getClient()->methodCallAsyncRead(
|
||||
'messages.sendReaction',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'msg_id' => $this->id,
|
||||
'reaction' => [is_int($reaction) ? ['_' => 'reactionCustomEmoji', 'document_id' => $reaction] : ['_' => 'reactionEmoji', 'emoticon' => $reaction]],
|
||||
]
|
||||
);
|
||||
unset($this->reactions[$reaction]);
|
||||
return $this->getClient()->wrapUpdate($result);
|
||||
}
|
||||
/**
|
||||
* React to message
|
||||
*
|
||||
@ -189,20 +262,6 @@ abstract class Message extends AbstractMessage
|
||||
* @param bool $addToRecent Add this reaction to the recent reactions list.
|
||||
* @return Update|null
|
||||
*/
|
||||
public function react(string|array $reaction,bool $big = false,bool $addToRecent = true) : ?Update
|
||||
{
|
||||
$result = $this->API->methodCallAsyncRead(
|
||||
'messages.sendReaction',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'msg_id' => $this->id,
|
||||
'reaction' => is_string($reaction) ? [['_' => 'reactionEmoji', 'emoticon' => $reaction]] : $reaction,
|
||||
'big' => $big,
|
||||
'add_to_recent' => $addToRecent
|
||||
]
|
||||
);
|
||||
return $this->API->wrapUpdate($result);
|
||||
}
|
||||
|
||||
private readonly string $html;
|
||||
private readonly string $htmlTelegram;
|
||||
|
Loading…
Reference in New Issue
Block a user