From b132c2c9821868d2bd42c538fa489e04d88b2663 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 7 Oct 2024 15:41:23 -0400 Subject: [PATCH] Updated ForceReply --- src/TgBotLib/Objects/ForceReply.php | 46 +++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/TgBotLib/Objects/ForceReply.php b/src/TgBotLib/Objects/ForceReply.php index c205bd2..6147c41 100644 --- a/src/TgBotLib/Objects/ForceReply.php +++ b/src/TgBotLib/Objects/ForceReply.php @@ -21,6 +21,18 @@ return $this->force_reply; } + /** + * Sets the force reply + * + * @param bool $force_reply + * @return ForceReply + */ + public function setForceReply(bool $force_reply): ForceReply + { + $this->force_reply = $force_reply; + return $this; + } + /** * Optional. The placeholder to be shown in the input field when the reply is active; 1-64 characters * @@ -31,6 +43,18 @@ return $this->inline_field_placeholder; } + /** + * Sets the placeholder to be shown in the input field when the reply is active; 1-64 characters + * + * @param string|null $inline_field_placeholder + * @return ForceReply + */ + public function setInlineFieldPlaceholder(?string $inline_field_placeholder): ForceReply + { + $this->inline_field_placeholder = $inline_field_placeholder; + return $this; + } + /** * Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are * @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), @@ -43,16 +67,34 @@ return $this->selective; } + /** + * Sets the selective + * + * @param bool $selective + * @return ForceReply + */ + public function setSelective(bool $selective): ForceReply + { + $this->selective = $selective; + return $this; + } + /** * @inheritDoc */ public function toArray(): array { - return [ + $array = [ 'force_reply' => $this->force_reply, - 'inline_field_placeholder' => $this->inline_field_placeholder, 'selective' => $this->selective, ]; + + if($this->inline_field_placeholder !== null) + { + $array['inline_field_placeholder'] = $this->inline_field_placeholder; + } + + return $array; } /**