-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-message.html
More file actions
45 lines (43 loc) · 43.6 KB
/
get-message.html
File metadata and controls
45 lines (43 loc) · 43.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Botfire : getMessage Method Documentation | BotFire</title>
<meta name="description" content="Modern PHP library for building Telegram bots based on Telegram standard documents">
<meta name="generator" content="VitePress v1.6.3">
<link rel="preload stylesheet" href="/assets/style.CwNnKCVM.css" as="style">
<link rel="preload stylesheet" href="/vp-icons.css" as="style">
<script type="module" src="/assets/app.DFUi-2C1.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.BBfruyGz.js">
<link rel="modulepreload" href="/assets/chunks/framework.BtEkjhVd.js">
<link rel="modulepreload" href="/assets/get-message.md.B6LtXM3H.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-d8b57b2d><!--[--><!--]--><!--[--><span tabindex="-1" data-v-fcbfc0e0></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-fcbfc0e0>Skip to content</a><!--]--><!----><header class="VPNav" data-v-d8b57b2d data-v-7ad780c2><div class="VPNavBar" data-v-7ad780c2 data-v-9fd4d1dd><div class="wrapper" data-v-9fd4d1dd><div class="container" data-v-9fd4d1dd><div class="title" data-v-9fd4d1dd><div class="VPNavBarTitle has-sidebar" data-v-9fd4d1dd data-v-9f43907a><a class="title" href="/" data-v-9f43907a><!--[--><!--]--><!----><span data-v-9f43907a>BotFire</span><!--[--><!--]--></a></div></div><div class="content" data-v-9fd4d1dd><div class="content-body" data-v-9fd4d1dd><!--[--><!--]--><div class="VPNavBarSearch search" data-v-9fd4d1dd><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-9fd4d1dd data-v-afb2845e><span id="main-nav-aria-label" class="visually-hidden" data-v-afb2845e> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-afb2845e data-v-815115f5><!--[--><span data-v-815115f5>Home</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-9fd4d1dd data-v-3f90c1a5><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-3f90c1a5 data-v-be9742d9 data-v-b4ccac88><span class="check" data-v-b4ccac88><span class="icon" data-v-b4ccac88><!--[--><span class="vpi-sun sun" data-v-be9742d9></span><span class="vpi-moon moon" data-v-be9742d9></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-9fd4d1dd data-v-ef6192dc data-v-e71e869c><!--[--><a class="VPSocialLink no-icon" href="https://github.com/botfire/botfire" aria-label="github" target="_blank" rel="noopener" data-v-e71e869c data-v-60a9a2d3><span class="vpi-social-github"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-9fd4d1dd data-v-f953d92f data-v-bfe7971f><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-bfe7971f><span class="vpi-more-horizontal icon" data-v-bfe7971f></span></button><div class="menu" data-v-bfe7971f><div class="VPMenu" data-v-bfe7971f data-v-20ed86d6><!----><!--[--><!--[--><!----><div class="group" data-v-f953d92f><div class="item appearance" data-v-f953d92f><p class="label" data-v-f953d92f>Appearance</p><div class="appearance-action" data-v-f953d92f><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-f953d92f data-v-be9742d9 data-v-b4ccac88><span class="check" data-v-b4ccac88><span class="icon" data-v-b4ccac88><!--[--><span class="vpi-sun sun" data-v-be9742d9></span><span class="vpi-moon moon" data-v-be9742d9></span><!--]--></span></span></button></div></div></div><div class="group" data-v-f953d92f><div class="item social-links" data-v-f953d92f><div class="VPSocialLinks social-links-list" data-v-f953d92f data-v-e71e869c><!--[--><a class="VPSocialLink no-icon" href="https://github.com/botfire/botfire" aria-label="github" target="_blank" rel="noopener" data-v-e71e869c data-v-60a9a2d3><span class="vpi-social-github"></span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-9fd4d1dd data-v-6bee1efd><span class="container" data-v-6bee1efd><span class="top" data-v-6bee1efd></span><span class="middle" data-v-6bee1efd></span><span class="bottom" data-v-6bee1efd></span></span></button></div></div></div></div><div class="divider" data-v-9fd4d1dd><div class="divider-line" data-v-9fd4d1dd></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-d8b57b2d data-v-2488c25a><div class="container" data-v-2488c25a><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-2488c25a><span class="vpi-align-left menu-icon" data-v-2488c25a></span><span class="menu-text" data-v-2488c25a>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-2488c25a data-v-6b867909><button data-v-6b867909>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-d8b57b2d data-v-42c4c606><div class="curtain" data-v-42c4c606></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-42c4c606><span class="visually-hidden" id="sidebar-aria-label" data-v-42c4c606> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-51288d80><section class="VPSidebarItem level-0" data-v-51288d80 data-v-0009425e><div class="item" role="button" tabindex="0" data-v-0009425e><div class="indicator" data-v-0009425e></div><h2 class="text" data-v-0009425e>Introduction</h2><!----></div><div class="items" data-v-0009425e><!--[--><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/what-is-botfire.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>What is BotFire</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/getting-started.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Getting Started</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-51288d80><section class="VPSidebarItem level-0 has-active" data-v-51288d80 data-v-0009425e><div class="item" role="button" tabindex="0" data-v-0009425e><div class="indicator" data-v-0009425e></div><h2 class="text" data-v-0009425e>Callback And Event Methods</h2><!----></div><div class="items" data-v-0009425e><!--[--><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/get-event.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Get Event</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/get-message.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Get Message</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/get-callback.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Get Callback</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-51288d80><section class="VPSidebarItem level-0" data-v-51288d80 data-v-0009425e><div class="item" role="button" tabindex="0" data-v-0009425e><div class="indicator" data-v-0009425e></div><h2 class="text" data-v-0009425e>Send Methods</h2><!----></div><div class="items" data-v-0009425e><!--[--><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-message.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Message</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-photo.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Photo</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-video.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Video</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-audio.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Audio</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-voice.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Voice</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-document.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Document</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/send-methods/send-chat-action.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Send Chat Action</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-51288d80><section class="VPSidebarItem level-0" data-v-51288d80 data-v-0009425e><div class="item" role="button" tabindex="0" data-v-0009425e><div class="indicator" data-v-0009425e></div><h2 class="text" data-v-0009425e>Helpers</h2><!----></div><div class="items" data-v-0009425e><!--[--><div class="VPSidebarItem level-1 is-link" data-v-0009425e data-v-0009425e><div class="item" data-v-0009425e><div class="indicator" data-v-0009425e></div><a class="VPLink link link" href="/markdown-builder.html" data-v-0009425e><!--[--><p class="text" data-v-0009425e>Markdown Builder</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-d8b57b2d data-v-9a6c75ad><div class="VPDoc has-sidebar has-aside" data-v-9a6c75ad data-v-e6f2a212><!--[--><!--]--><div class="container" data-v-e6f2a212><div class="aside" data-v-e6f2a212><div class="aside-curtain" data-v-e6f2a212></div><div class="aside-container" data-v-e6f2a212><div class="aside-content" data-v-e6f2a212><div class="VPDocAside" data-v-e6f2a212 data-v-cb998dce><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-cb998dce data-v-f610f197><div class="content" data-v-f610f197><div class="outline-marker" data-v-f610f197></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-f610f197>On this page</div><ul class="VPDocOutlineItem root" data-v-f610f197 data-v-53c99d69><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-cb998dce></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-e6f2a212><div class="content-container" data-v-e6f2a212><!--[--><!--]--><main class="main" data-v-e6f2a212><div style="position:relative;" class="vp-doc _get-message" data-v-e6f2a212><div><h1 id="botfire-getmessage-method-documentation" tabindex="-1">Botfire : <code>getMessage</code> Method Documentation <a class="header-anchor" href="#botfire-getmessage-method-documentation" aria-label="Permalink to "Botfire : `getMessage` Method Documentation""></a></h1><h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to "Overview""></a></h2><p>The <code>getMessage</code> method is a key component of the Botfire for creating Telegram bots. It provides access to the details of a message received via Telegram webhooks, enabling developers to extract and process various aspects of the message, such as its content type, sender information, and metadata.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage""></a></h2><p>To access the <code>getMessage</code> method, use the <code>Bot</code> class as follows:</p><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">use</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Botfire\Bot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$message </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h2 id="methods" tabindex="-1">Methods <a class="header-anchor" href="#methods" aria-label="Permalink to "Methods""></a></h2><p>The <code>getMessage</code> method returns an object with the following methods to extract specific information about the message:</p><h3 id="_1-getcontenttype" tabindex="-1">1. <code>getContentType()</code> <a class="header-anchor" href="#_1-getcontenttype" aria-label="Permalink to "1. `getContentType()`""></a></h3><p>Returns the type of content contained in the message.</p><h4 id="example" tabindex="-1">Example <a class="header-anchor" href="#example" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$type </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getContentType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h4 id="possible-content-types" tabindex="-1">Possible Content Types <a class="header-anchor" href="#possible-content-types" aria-label="Permalink to "Possible Content Types""></a></h4><p>The content type can be one of the following constants defined in the <code>GetMessage</code> class:</p><ul><li><code>GetMessage::TYPE_TEXT</code> (<code>'text'</code>) - A text message.</li><li><code>GetMessage::TYPE_PHOTO</code> (<code>'photo'</code>) - A photo message.</li><li><code>GetMessage::TYPE_VIDEO</code> (<code>'video'</code>) - A video message.</li><li><code>GetMessage::TYPE_AUDIO</code> (<code>'audio'</code>) - An audio message.</li><li><code>GetMessage::TYPE_DOCUMENT</code> (<code>'document'</code>) - A document/file message.</li><li><code>GetMessage::TYPE_STICKER</code> (<code>'sticker'</code>) - A sticker message.</li><li><code>GetMessage::TYPE_ANIMATION</code> (<code>'animation'</code>) - An animation (GIF) message.</li><li><code>GetMessage::TYPE_LOCATION</code> (<code>'location'</code>) - A location message.</li><li><code>GetMessage::TYPE_CONTACT</code> (<code>'contact'</code>) - A contact message.</li><li><code>GetMessage::TYPE_VOICE</code> (<code>'voice'</code>) - A voice message.</li><li><code>GetMessage::TYPE_POLL</code> (<code>'poll'</code>) - A poll message.</li></ul><h4 id="example-usage" tabindex="-1">Example Usage <a class="header-anchor" href="#example-usage" aria-label="Permalink to "Example Usage""></a></h4><p>To check if the message is a text message:</p><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">use</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Botfire\Bot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">use</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Botfire\GetMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getContentType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">===</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> GetMessage</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TYPE_TEXT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Handle text message</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_2-getmessageid" tabindex="-1">2. <code>getMessageId()</code> <a class="header-anchor" href="#_2-getmessageid" aria-label="Permalink to "2. `getMessageId()`""></a></h3><p>Returns the unique identifier of the message.</p><h4 id="example-1" tabindex="-1">Example <a class="header-anchor" href="#example-1" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$message_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessageId</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_3-getdate" tabindex="-1">3. <code>getDate()</code> <a class="header-anchor" href="#_3-getdate" aria-label="Permalink to "3. `getDate()`""></a></h3><p>Returns the timestamp of when the message was sent.</p><h4 id="example-2" tabindex="-1">Example <a class="header-anchor" href="#example-2" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$date </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getDate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_4-gettext" tabindex="-1">4. <code>getText()</code> <a class="header-anchor" href="#_4-gettext" aria-label="Permalink to "4. `getText()`""></a></h3><p>Returns the text content of the message (applicable for text messages).</p><h4 id="example-3" tabindex="-1">Example <a class="header-anchor" href="#example-3" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$text </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getText</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_5-getcaption" tabindex="-1">5. <code>getCaption()</code> <a class="header-anchor" href="#_5-getcaption" aria-label="Permalink to "5. `getCaption()`""></a></h3><p>Returns the caption of the message, if available (applicable for messages with media content such as photos, videos, or documents).</p><h4 id="example-4" tabindex="-1">Example <a class="header-anchor" href="#example-4" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$caption </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getCaption</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_6-getfrom" tabindex="-1">6. <code>getFrom()</code> <a class="header-anchor" href="#_6-getfrom" aria-label="Permalink to "6. `getFrom()`""></a></h3><p>Returns an object representing the user or bot that sent the message. This object is an instance of the <code>User</code> class, as defined in the Telegram API (see <a href="https://core.telegram.org/bots/api#user" target="_blank" rel="noreferrer">Telegram API: User</a>).</p><h4 id="available-methods-for-getfrom" tabindex="-1">Available Methods for <code>getFrom()</code> <a class="header-anchor" href="#available-methods-for-getfrom" aria-label="Permalink to "Available Methods for `getFrom()`""></a></h4><ul><li><code>getId(): ?int</code> - Returns the unique identifier for the user or bot (up to 52 significant bits, safe for 64-bit integers or double-precision floats).</li><li><code>isBot(): bool</code> - Returns <code>true</code> if the sender is a bot.</li><li><code>getFirstName(): ?string</code> - Returns the sender's first name.</li><li><code>getLastName(): ?string</code> - Returns the sender's last name, if available.</li><li><code>getFullName(): ?string</code> - Returns the sender's full name (combines first and last names, if available).</li><li><code>getUsername(): ?string</code> - Returns the sender's username, if available.</li><li><code>getLanguageCode(): ?string</code> - Returns the IETF language tag of the sender's language, if available.</li><li><code>isPremium(): bool</code> - Returns <code>true</code> if the sender is a Telegram Premium user.</li><li><code>addedToAttachmentMenu(): bool</code> - Returns <code>true</code> if the sender added the bot to their attachment menu.</li></ul><h4 id="example-5" tabindex="-1">Example <a class="header-anchor" href="#example-5" aria-label="Permalink to "Example""></a></h4><p>To retrieve the sender's username:</p><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$username </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getFrom</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getUsername</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_7-getchat" tabindex="-1">7. <code>getChat()</code> <a class="header-anchor" href="#_7-getchat" aria-label="Permalink to "7. `getChat()`""></a></h3><p>Returns an object representing the chat where the message was sent, as described by the Telegram API: "Chat the message belongs to."</p><h4 id="available-methods-for-getchat" tabindex="-1">Available Methods for <code>getChat()</code> <a class="header-anchor" href="#available-methods-for-getchat" aria-label="Permalink to "Available Methods for `getChat()`""></a></h4><ul><li><code>getId(): ?int</code> - Returns the unique identifier for the chat.</li><li><code>getType(): ?string</code> - Returns the type of the chat (<code>'private'</code>, <code>'group'</code>, <code>'supergroup'</code>, or <code>'channel'</code>).</li><li><code>getTitle(): ?string</code> - Returns the title of the chat (for supergroups, channels, or group chats).</li><li><code>getUsername(): ?string</code> - Returns the chat's username, if available (for private chats, supergroups, or channels).</li><li><code>getFirstName(): ?string</code> - Returns the first name of the other party in a private chat, if available.</li><li><code>getLastName(): ?string</code> - Returns the last name of the other party in a private chat, if available.</li><li><code>getFullName(): ?string</code> - Returns the full name of the other party in a private chat (combines first and last names, if available).</li><li><code>isForum(): bool</code> - Returns <code>true</code> if the supergroup chat has topics enabled.</li></ul><h4 id="example-6" tabindex="-1">Example <a class="header-anchor" href="#example-6" aria-label="Permalink to "Example""></a></h4><p>To retrieve the chat ID:</p><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$chat_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getChat</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getId</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="_8-isreply-bool" tabindex="-1">8. <code>isReply(): bool</code> <a class="header-anchor" href="#_8-isreply-bool" aria-label="Permalink to "8. `isReply(): bool`""></a></h3><p>Returns <code>true</code> if the message is a reply to another message.</p><h4 id="example-7" tabindex="-1">Example <a class="header-anchor" href="#example-7" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isReply</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()) {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Handle reply message</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_9-hasquote-bool" tabindex="-1">9. <code>hasQuote(): bool</code> <a class="header-anchor" href="#_9-hasquote-bool" aria-label="Permalink to "9. `hasQuote(): bool`""></a></h3><p>Returns <code>true</code> if the message contains a quoted text.</p><h4 id="example-8" tabindex="-1">Example <a class="header-anchor" href="#example-8" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hasQuote</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()) {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Handle message with quote</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_10-getquote-textquote" tabindex="-1">10. <code>getQuote(): ?TextQuote</code> <a class="header-anchor" href="#_10-getquote-textquote" aria-label="Permalink to "10. `getQuote(): ?TextQuote`""></a></h3><p>Returns an instance of the <code>TextQuote</code> class representing the quoted text in the message, or <code>null</code> if no quote exists.</p><h4 id="example-9" tabindex="-1">Example <a class="header-anchor" href="#example-9" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$quote </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getQuote</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ($quote) {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Process the quoted text</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_11-getreplytomessage-getmessage" tabindex="-1">11. <code>getReplyToMessage(): ?GetMessage</code> <a class="header-anchor" href="#_11-getreplytomessage-getmessage" aria-label="Permalink to "11. `getReplyToMessage(): ?GetMessage`""></a></h3><p>Returns the message that the current message is replying to, if it exists. If the message is not a reply, this method returns <code>null</code>. The returned object is an instance of the <code>GetMessage</code> class, allowing access to the same methods as the original message.</p><h4 id="example-10" tabindex="-1">Example <a class="header-anchor" href="#example-10" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$reply_message </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getReplyToMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ($reply_message) {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Process the replied-to message</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $reply_text </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $reply_message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getText</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $content_type </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $reply_message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getContentType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_12-deletethismessage-bool" tabindex="-1">12. <code>deleteThisMessage(): bool</code> <a class="header-anchor" href="#_12-deletethismessage-bool" aria-label="Permalink to "12. `deleteThisMessage(): bool`""></a></h3><p>Deletes the current message from the chat. This method uses the message's ID and the chat's ID to perform the deletion via the <code>Bot::deleteMessage()</code> method.</p><h4 id="example-11" tabindex="-1">Example <a class="header-anchor" href="#example-11" aria-label="Permalink to "Example""></a></h4><div class="language-php vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">Bot</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">::</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">deleteThisMessage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h2 id="notes" tabindex="-1">Notes <a class="header-anchor" href="#notes" aria-label="Permalink to "Notes""></a></h2><ul><li>The <code>getMessage</code> method is designed to handle messages received via Telegram webhooks, providing a structured way to access message details.</li><li>Use <code>getContentType()</code> to determine the type of message content and handle it appropriately in your bot logic.</li><li>The <code>getFrom()</code> and <code>getChat()</code> methods provide detailed information about the sender and the chat context, respectively, aligning with Telegram's API specifications.</li><li>The event type check methods (e.g., <code>isCallbackQuery()</code>, <code>isEditedMessage()</code>) rely on the <code>GetEvent</code> class and are useful for filtering specific event types.</li><li>The <code>getMessageId()</code> and <code>getDate()</code> methods are useful for tracking and logging messages.</li><li>The <code>getText()</code> and <code>getCaption()</code> methods provide access to textual content, while <code>getQuote()</code> and <code>hasQuote()</code> allow handling of quoted messages.</li><li>For more details on the <code>User</code> and <code>Chat</code> objects, refer to the Telegram API documentation: <a href="https://core.telegram.org/bots/api#user" target="_blank" rel="noreferrer">User</a> and <a href="https://core.telegram.org/bots/api#chat" target="_blank" rel="noreferrer">Chat</a>.</li></ul></div></div></main><footer class="VPDocFooter" data-v-e6f2a212 data-v-1bcd8184><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-1bcd8184><span class="visually-hidden" id="doc-footer-aria-label" data-v-1bcd8184>Pager</span><div class="pager" data-v-1bcd8184><a class="VPLink link pager-link prev" href="/get-event.html" data-v-1bcd8184><!--[--><span class="desc" data-v-1bcd8184>Previous page</span><span class="title" data-v-1bcd8184>Get Event</span><!--]--></a></div><div class="pager" data-v-1bcd8184><a class="VPLink link pager-link next" href="/get-callback.html" data-v-1bcd8184><!--[--><span class="desc" data-v-1bcd8184>Next page</span><span class="title" data-v-1bcd8184>Get Callback</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"api-examples.md\":\"CZgeTbws\",\"get-callback.md\":\"CFR9JqkM\",\"get-event.md\":\"Dib-Xa5v\",\"get-message.md\":\"B6LtXM3H\",\"getting-started.md\":\"D3rJQbUn\",\"index.md\":\"BczpqHIO\",\"keyboards.md\":\"tWbTBElv\",\"markdown-builder.md\":\"BgzUhTuF\",\"markdown-examples.md\":\"naTJisab\",\"readme.md\":\"Dgkstt0F\",\"send-methods_send-animation.md\":\"Kw1naLFp\",\"send-methods_send-audio.md\":\"Uw9hq7fE\",\"send-methods_send-chat-action.md\":\"BAQiU1EE\",\"send-methods_send-document.md\":\"BrPXPYrU\",\"send-methods_send-message.md\":\"DfQOoxAn\",\"send-methods_send-photo.md\":\"CMLTYf1Y\",\"send-methods_send-video.md\":\"DfzpbjIO\",\"send-methods_send-voice.md\":\"DJTpe9aM\",\"what-is-botfire.md\":\"D-1Vt8NY\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"BotFire\",\"description\":\"Modern PHP library for building Telegram bots based on Telegram standard documents\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"Home\",\"link\":\"/\"}],\"sidebar\":[{\"text\":\"Introduction\",\"items\":[{\"text\":\"What is BotFire\",\"link\":\"/what-is-botfire\"},{\"text\":\"Getting Started\",\"link\":\"/getting-started\"}]},{\"text\":\"Callback And Event Methods\",\"items\":[{\"text\":\"Get Event\",\"link\":\"/get-event\"},{\"text\":\"Get Message\",\"link\":\"/get-message\"},{\"text\":\"Get Callback\",\"link\":\"/get-callback\"}]},{\"text\":\"Send Methods\",\"items\":[{\"text\":\"Send Message\",\"link\":\"/send-methods/send-message\"},{\"text\":\"Send Photo\",\"link\":\"/send-methods/send-photo\"},{\"text\":\"Send Video\",\"link\":\"/send-methods/send-video\"},{\"text\":\"Send Audio\",\"link\":\"/send-methods/send-audio\"},{\"text\":\"Send Voice\",\"link\":\"/send-methods/send-voice\"},{\"text\":\"Send Document\",\"link\":\"/send-methods/send-document\"},{\"text\":\"Send Chat Action\",\"link\":\"/send-methods/send-chat-action\"}]},{\"text\":\"Helpers\",\"items\":[{\"text\":\"Markdown Builder\",\"link\":\"/markdown-builder\"}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/botfire/botfire\"}]},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
</body>
</html>