@@ -47,15 +47,109 @@ $chatMessage->options($telegramOptions);
4747$chatter->send($chatMessage);
4848```
4949
50- Adding Photo to a Message
50+ Adding files to a Message
5151-------------------------
5252
5353With a Telegram message, you can use the ` TelegramOptions ` class to add
5454[ message options] ( https://core.telegram.org/bots/api ) .
5555
56+ > :warning : ** WARNING**
57+ In one message you can send only one file
58+
59+ [ Telegram supports 3 ways] ( https://core.telegram.org/bots/api#sending-files ) for passing files:
60+
61+ * You can send files by passing public http url to option:
62+ * Photo
63+ ``` php
64+ $telegramOptions = (new TelegramOptions())
65+ ->photo('https://localhost/photo.mp4');
66+ ```
67+ * Video
68+ ```php
69+ $telegramOptions = (new TelegramOptions())
70+ ->video('https://localhost/video.mp4');
71+ ```
72+ * Animation
73+ ```php
74+ $telegramOptions = (new TelegramOptions())
75+ ->animation('https://localhost/animation.gif');
76+ ```
77+ * Audio
78+ ```php
79+ $telegramOptions = (new TelegramOptions())
80+ ->audio('https://localhost/audio.ogg');
81+ ```
82+ * Document
83+ ```php
84+ $telegramOptions = (new TelegramOptions())
85+ ->document('https://localhost/document.odt');
86+ ```
87+ * Sticker
88+ ```php
89+ $telegramOptions = (new TelegramOptions())
90+ ->sticker('https://localhost/sticker.webp', '🤖');
91+ ```
92+ * You can send files by passing local path to option, in this case file will be sent via multipart/form-data:
93+ * Photo
94+ ```php
95+ $telegramOptions = (new TelegramOptions())
96+ ->uploadPhoto('files/photo.png');
97+ ```
98+ * Video
99+ ```php
100+ $telegramOptions = (new TelegramOptions())
101+ ->uploadVideo('files/video.mp4');
102+ ```
103+ * Animation
104+ ```php
105+ $telegramOptions = (new TelegramOptions())
106+ ->uploadAnimation('files/animation.gif');
107+ ```
108+ * Audio
109+ ```php
110+ $telegramOptions = (new TelegramOptions())
111+ ->uploadAudio('files/audio.ogg');
112+ ```
113+ * Document
114+ ```php
115+ $telegramOptions = (new TelegramOptions())
116+ ->uploadDocument('files/document.odt');
117+ ```
118+ * Sticker
119+ ```php
120+ $telegramOptions = (new TelegramOptions())
121+ ->uploadSticker('files/sticker.webp', '🤖');
122+ ```
123+ * You can send files by passing file_id to option:
124+ * Photo
125+ ```php
126+ $telegramOptions = (new TelegramOptions())
127+ ->photo('ABCDEF');
128+ ```
129+ * Video
130+ ```php
131+ $telegramOptions = (new TelegramOptions())
132+ ->video('ABCDEF');
133+ ```
134+ * Animation
135+ ```php
136+ $telegramOptions = (new TelegramOptions())
137+ ->animation('ABCDEF');
138+ ```
139+ * Audio
140+ ```php
141+ $telegramOptions = (new TelegramOptions())
142+ ->audio('ABCDEF');
143+ ```
144+ * Document
145+ ```php
146+ $telegramOptions = (new TelegramOptions())
147+ ->document('ABCDEF');
148+ ```
149+ * Sticker - *Can't be sent using file_id*
150+
151+ Full example:
56152```php
57- use Symfony\Component\Notifier\Bridge\Telegram\Reply\Markup\Button\InlineKeyboardButton;
58- use Symfony\Component\Notifier\Bridge\Telegram\Reply\Markup\InlineKeyboardMarkup;
59153use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
60154use Symfony\Component\Notifier\Message\ChatMessage;
61155
@@ -76,6 +170,86 @@ $chatMessage->options($telegramOptions);
76170$chatter->send($chatMessage);
77171```
78172
173+ Adding Location to a Message
174+ ----------------------------
175+
176+ With a Telegram message, you can use the ` TelegramOptions ` class to add
177+ [ message options] ( https://core.telegram.org/bots/api ) .
178+
179+ ``` php
180+ use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
181+ use Symfony\Component\Notifier\Message\ChatMessage;
182+
183+ $chatMessage = new ChatMessage('');
184+
185+ // Create Telegram options
186+ $telegramOptions = (new TelegramOptions())
187+ ->chatId('@symfonynotifierdev')
188+ ->parseMode('MarkdownV2')
189+ ->location(48.8566, 2.3522);
190+
191+ // Add the custom options to the chat message and send the message
192+ $chatMessage->options($telegramOptions);
193+
194+ $chatter->send($chatMessage);
195+ ```
196+
197+ Adding Venue to a Message
198+ ----------------------------
199+
200+ With a Telegram message, you can use the ` TelegramOptions ` class to add
201+ [ message options] ( https://core.telegram.org/bots/api ) .
202+
203+ ``` php
204+ use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
205+ use Symfony\Component\Notifier\Message\ChatMessage;
206+
207+ $chatMessage = new ChatMessage('');
208+
209+ // Create Telegram options
210+ $telegramOptions = (new TelegramOptions())
211+ ->chatId('@symfonynotifierdev')
212+ ->parseMode('MarkdownV2')
213+ ->venue(48.8566, 2.3522, 'Center of Paris', 'France, Paris');
214+
215+ // Add the custom options to the chat message and send the message
216+ $chatMessage->options($telegramOptions);
217+
218+ $chatter->send($chatMessage);
219+ ```
220+
221+ Adding Contact to a Message
222+ ----------------------------
223+
224+ With a Telegram message, you can use the ` TelegramOptions ` class to add
225+ [ message options] ( https://core.telegram.org/bots/api ) .
226+
227+ ``` php
228+ use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
229+ use Symfony\Component\Notifier\Message\ChatMessage;
230+
231+ $chatMessage = new ChatMessage('');
232+
233+ $vCard = 'BEGIN:VCARD
234+ VERSION:3.0
235+ N:Doe;John;;;
236+ FN:John Doe
237+ EMAIL;type=INTERNET;type=WORK;type=pref:
[email protected] 238+ TEL;type=WORK;type=pref:+330186657200
239+ END:VCARD';
240+
241+ // Create Telegram options
242+ $telegramOptions = (new TelegramOptions())
243+ ->chatId('@symfonynotifierdev')
244+ ->parseMode('MarkdownV2')
245+ ->contact('+330186657200', 'John', 'Doe', $vCard);
246+
247+ // Add the custom options to the chat message and send the message
248+ $chatMessage->options($telegramOptions);
249+
250+ $chatter->send($chatMessage);
251+ ```
252+
79253Updating Messages
80254-----------------
81255
0 commit comments