Skip to content

Commit 93ce83b

Browse files
committed
Added getTrigger()
1 parent 5d40f10 commit 93ce83b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Telegram/Update.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,30 @@ public function getUser(): ?object
156156

157157
return $this->customs['user'];
158158
}
159+
160+
/**
161+
* Returns the trigger of the update.
162+
* A textual message in the chat.
163+
* i.e. A command, a caption, a callback data, ...
164+
*
165+
* @return string|null A string rappresenting the trigger.
166+
*/
167+
public function getTrigger(): ?string
168+
{
169+
if(!isset($this->customs['trigger'])) {
170+
$message = $this->data->message ??
171+
$this->data->edited_message ??
172+
$this->data->channel_post ??
173+
$this->data->edited_channel_post ??
174+
null;
175+
176+
$this->customs['trigger'] = $message->text ??
177+
$message->caption ??
178+
$this->data->inline_query->query ??
179+
$this->data->callback_query->data ??
180+
null;
181+
}
182+
183+
return $this->customs['trigger'];
184+
}
159185
}

0 commit comments

Comments
 (0)