xxtelebot  1.4.1.0
A simple Telegram Bot implementation in C++
types.h
1 #ifndef TGBOT_METHODS_TYPES_H
2 #define TGBOT_METHODS_TYPES_H
3 
4 #include "../types.h"
5 
6 namespace tgbot {
7 
8  namespace methods {
9 
13  namespace types {
14 
15  constexpr char iqrTypeArticle[] = "article";
16  constexpr char iqrTypeDocument[] = "document";
17  constexpr char iqrTypeGif[] = "gif";
18  constexpr char iqrTypeMpeg4Gif[] = "mpeg4_gif";
19  constexpr char iqrTypePhoto[] = "photo";
20  constexpr char iqrTypeVideo[] = "video";
21  constexpr char iqrTypeAudio[] = "audio";
22  constexpr char iqrTypeLocation[] = "location";
23  constexpr char iqrTypeVenue[] = "venue";
24  constexpr char iqrTypeContact[] = "contact";
25  constexpr char iqrTypeGame[] = "game";
26  constexpr char iqrTypeVoice[] = "voice";
27 
28  constexpr char imTypePhoto[] = "photo";
29  constexpr char imTypeVideo[] = "video";
30  constexpr char imTypeAudio[] = "audio";
31  constexpr char imTypeAnimation[] = "animation";
32  constexpr char imTypeDocument[] = "document";
33 
34  struct InputMessageContent;
35  struct InlineQueryResult;
36 
37  using InlineQueryResultsVector =
38  std::vector<::tgbot::types::Ptr<InlineQueryResult>>;
39 
42 
46  enum class ParseMode {
47  DEFAULT, MARKDOWN, HTML
48  };
49 
53  enum class ChatAction {
54  TYPING,
55  UPLOAD_PHOTO,
56  RECORD_VIDEO,
57  UPLOAD_VIDEO,
58  RECORD_AUDIO,
59  UPLOAD_AUDIO,
60  UPLOAD_DOCUMENT,
61  FIND_LOCATION,
62  RECORD_VIDEO_NOTE,
63  UPLOAD_VIDEO_NOTE
64  };
65 
70  enum class FileSource {
74  EXTERNAL,
75 
80  };
81 
82  struct LoginUrl {
83  public:
84  std::string url;
85  ::tgbot::types::Ptr<std::string> forwardText;
86  ::tgbot::types::Ptr<std::string> botUsername;
87  bool requestWriteAccess;
88  };
89 
91  public:
92  bool canSendMessages : 1;
93  bool canSendMediaMessages : 1;
94  bool canSendOtherMessages : 1;
95  bool canAddWebPagePreviews : 1;
96  };
97 
99  public:
100  bool canPostMessages : 1;
101  bool canChangeInfo : 1;
102  bool canEditMessages : 1;
103  bool canDeleteMessages : 1;
104  bool canInviteUsers : 1;
105  bool canRestrictMembers : 1;
106  bool canPinMessages : 1;
107  bool canPromoteMembers : 1;
108  };
109 
111  public:
112  std::string text;
113  ::tgbot::types::Ptr<std::string> url;
114  ::tgbot::types::Ptr<LoginUrl> loginUrl;
115  ::tgbot::types::Ptr<std::string> callbackData;
116  ::tgbot::types::Ptr<std::string> switchInlineQuery;
117  ::tgbot::types::Ptr<std::string> switchInlineQueryCurrentChat;
122  bool pay : 1;
123  };
124 
125 //
126 // ReplyMarkup
127 //
128  struct ReplyMarkup {
129  public:
130  // Not explicit constructor
131  ReplyMarkup() = default;
132 
133  ReplyMarkup(const char *customMarkup);
134 
135  ReplyMarkup(const std::string &customMarkup);
136 
137  virtual ~ReplyMarkup() = default;
138 
139  template<typename T>
140  inline ReplyMarkup& operator=(T &&customMarkup) {
141  what = std::forward<T>(customMarkup);
142  return *this;
143  }
144 
145  virtual std::string toString() const;
146 
147  private:
148  std::string what;
149  };
150 
152  public:
153  std::string toString() const override;
154 
155  std::vector<std::vector<InlineKeyboardButton>> inlineKeyboard;
156  };
157 
159  public:
160  std::string toString() const override;
161 
162  std::vector<std::vector<KeyboardButton>> keyboard;
163  bool resizeKeyboard : 1;
164  bool oneTimeKeyboard : 1;
165  bool selective : 1;
166  };
167 
169  public:
170  std::string toString() const override;
171 
172  bool selective : 1;
173  };
174 
175  struct ForceReply : public ReplyMarkup {
176  public:
177  std::string toString() const override;
178 
179  bool selective : 1;
180  };
181 
182 //
183 // InputMessageContent
184 //
186  public:
187  // Not explicit constructor
188  InputMessageContent() = default;
189 
190  InputMessageContent(const char *customMarkup);
191 
192  InputMessageContent(const std::string &customMarkup);
193 
194  virtual ~InputMessageContent() = default;
195 
196  template<typename T>
197  inline InputMessageContent& operator=(T &&customMarkup) {
198  what = std::forward<T>(customMarkup);
199  return *this;
200  }
201 
202  virtual std::string toString() const;
203 
204  private:
205  std::string what;
206  };
207 
209  public:
210  std::string toString() const override;
211 
212  std::string messageText;
213  ParseMode parseMode;
214  bool disableWebPagePreview : 1;
215  };
216 
218  public:
219  std::string toString() const override;
220 
221  double latitude;
222  double longitude;
223  };
224 
226  public:
227  std::string toString() const override;
228 
229  std::string phoneNumber;
230  std::string firstName;
231  ::tgbot::types::Ptr<std::string> lastName;
232  };
233 
235  public:
236  std::string toString() const override;
237 
238  std::string title;
239  std::string address;
240  ::tgbot::types::Ptr<std::string> foursquareId;
241  ::tgbot::types::Ptr<std::string> foursquareType;
242  double latitude;
243  double longitude;
244  };
245 
246 //
247 // InlineQueryResult
248 //
250  public:
251  // Not explicit constructor
252  InlineQueryResult() = default;
253 
254  InlineQueryResult(const char *customMarkup);
255 
256  InlineQueryResult(const std::string &customMarkup);
257 
258  virtual ~InlineQueryResult() = default;
259 
260  virtual std::string toString() const;
261 
262  template<typename T>
263  inline InlineQueryResult& operator=(T &&customMarkup) {
264  what = std::forward<T>(customMarkup);
265  return *this;
266  }
267 
268  std::string type;
269  std::string id;
270 
271  private:
272  std::string what;
273  };
274 
276  public:
277  std::string toString() const override;
278 
279  std::string audioUrl;
280  std::string title;
281  InputMessageContent inputMessageContent;
282  ::tgbot::types::Ptr<std::string> caption;
283  ::tgbot::types::Ptr<std::string> performer;
284  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
285  int audioDuration;
286  };
287 
289  public:
290  std::string toString() const override;
291 
292  std::string title;
293  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
294  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
295  ::tgbot::types::Ptr<std::string> url;
296  ::tgbot::types::Ptr<std::string> description;
297  ::tgbot::types::Ptr<std::string> thumbUrl;
298  int thumbWidth;
299  int thumbHeight;
300  bool hideUrl : 1;
301  };
302 
304  public:
305  std::string toString() const override;
306 
307  std::string phoneNumber;
308  std::string firstName;
309  ::tgbot::types::Ptr<std::string> lastName;
310  ::tgbot::types::Ptr<std::string> thumbUrl;
311  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
312  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
313  int thumbWidth;
314  int thumbHeight;
315  };
316 
318  public:
319  std::string toString() const override;
320 
321  std::string gameShortName;
322  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
323  };
324 
326  public:
327  std::string toString() const override;
328 
329  std::string title;
330  std::string documentUrl;
331  std::string mimeType;
332  ::tgbot::types::Ptr<std::string> caption;
333  ::tgbot::types::Ptr<std::string> description;
334  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
335  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
336  ::tgbot::types::Ptr<std::string> thumbUrl;
337  int thumbWidth;
338  int thumbHeight;
339  };
340 
342  public:
343  std::string toString() const override;
344 
345  std::string gifUrl;
346  std::string thumbUrl;
347  ::tgbot::types::Ptr<std::string> title;
348  ::tgbot::types::Ptr<std::string> caption;
349  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
350  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
351  int gifWidth;
352  int gifHeight;
353  int gifDuration;
354  };
355 
357  public:
358  std::string toString() const override;
359 
360  std::string title;
361  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
362  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
363  ::tgbot::types::Ptr<std::string> thumbUrl;
364  double latitude;
365  double longitude;
366  int thumbWidth;
367  int thumbHeight;
368  };
369 
371  public:
372  std::string toString() const override;
373 
374  std::string mpeg4Url;
375  std::string thumbUrl;
376  ::tgbot::types::Ptr<std::string> title;
377  ::tgbot::types::Ptr<std::string> caption;
378  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
379  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
380  int mpeg4Width;
381  int mpeg4Height;
382  int mpeg4Duration;
383  };
384 
386  public:
387  std::string toString() const override;
388 
389  std::string photoUrl;
390  std::string thumbUrl;
391  ::tgbot::types::Ptr<std::string> title;
392  ::tgbot::types::Ptr<std::string> description;
393  ::tgbot::types::Ptr<std::string> caption;
394  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
395  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
396  int photoWidth;
397  int photoHeight;
398  };
399 
401  public:
402  std::string toString() const override;
403 
404  std::string title;
405  std::string address;
406  ::tgbot::types::Ptr<std::string> foursquareId;
407  ::tgbot::types::Ptr<std::string> foursquareType;
408  ::tgbot::types::Ptr<std::string> thumbUrl;
409  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
410  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
411  double latitude;
412  double longitude;
413  int thumbWidth;
414  int thumbHeight;
415  };
416 
418  public:
419  std::string toString() const override;
420 
421  std::string videoUrl;
422  std::string mimeType;
423  std::string thumbUrl;
424  std::string title;
425  ::tgbot::types::Ptr<std::string> caption;
426  ::tgbot::types::Ptr<std::string> description;
427  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
428  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
429  int videoWidth;
430  int videoHeight;
431  int videoDuration;
432  };
433 
435  public:
436  std::string toString() const override;
437 
438  std::string title;
439  std::string voiceUrl;
440  ::tgbot::types::Ptr<std::string> caption;
441  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
442  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
443  int voiceDuration;
444  };
445 
447  public:
448  std::string toString() const override;
449 
450  std::string audioFileId;
451  ::tgbot::types::Ptr<std::string> caption;
452  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
453  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
454  };
455 
457  public:
458  std::string toString() const override;
459 
460  std::string documentFileId;
461  std::string title;
462  ::tgbot::types::Ptr<std::string> description;
463  ::tgbot::types::Ptr<std::string> caption;
464  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
465  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
466  };
467 
469  public:
470  std::string toString() const override;
471 
472  std::string gifFileId;
473  ::tgbot::types::Ptr<std::string> title;
474  ::tgbot::types::Ptr<std::string> caption;
475  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
476  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
477  };
478 
480  public:
481  std::string toString() const override;
482 
483  std::string mpeg4FileId;
484  ::tgbot::types::Ptr<std::string> title;
485  ::tgbot::types::Ptr<std::string> caption;
486  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
487  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
488  };
489 
491  public:
492  std::string toString() const override;
493 
494  std::string photoFileId;
495  ::tgbot::types::Ptr<std::string> title;
496  ::tgbot::types::Ptr<std::string> description;
497  ::tgbot::types::Ptr<std::string> caption;
498  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
499  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
500  };
501 
503  public:
504  std::string toString() const override;
505 
506  std::string stickerFileId;
507  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
508  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
509  };
510 
512  public:
513  std::string toString() const override;
514 
515  std::string title;
516  std::string videoFileId;
517  ::tgbot::types::Ptr<std::string> description;
518  ::tgbot::types::Ptr<std::string> caption;
519  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
520  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
521  };
522 
524  public:
525  std::string toString() const override;
526 
527  std::string title;
528  std::string voiceFileId;
529  ::tgbot::types::Ptr<std::string> caption;
530  ::tgbot::types::Ptr<InputMessageContent> inputMessageContent;
531  ::tgbot::types::Ptr<InlineKeyboardMarkup> replyMarkup;
532  };
533 
534  struct LabeledPrice {
535  public:
536  std::string label;
537  int amount;
538  };
539 
543  struct Invoice {
544  public:
545  std::vector<LabeledPrice> prices;
546  std::string title;
547  std::string description;
548  std::string payload;
549  std::string providerToken;
550  std::string startParameter;
551  std::string currency;
552  ::tgbot::types::Ptr<std::string> photoUrl;
553  ::tgbot::types::Ptr<std::string> providerData;
554  int photoSize;
555  int photoWidth;
556  int photoHeight;
557  bool needName : 1;
558  bool needPhoneNumber : 1;
559  bool needEmail : 1;
560  bool needShippingAddress : 1;
561  bool isFlexible : 1;
562  bool sendPhoneNumberToProvider : 1;
563  bool sendEmailToProvider : 1;
564  };
565 
566  struct ShippingOption {
567  public:
568  std::vector<LabeledPrice> prices;
569  std::string id;
570  std::string title;
571  };
572 
573 //
574 // InputMedia
575 //
576  struct InputMedia {
577  public:
578 
579  InputMedia() = default;
580 
581  InputMedia(const char *_what);
582 
583  InputMedia(const std::string &_what);
584 
585  virtual ~InputMedia() = default;
586 
587  template<typename T>
588  inline InputMedia& operator=(T &&customMarkup) {
589  what = std::forward<T>(customMarkup);
590  return *this;
591  }
592 
593  virtual std::string toString() const;
594 
595  std::string type;
596  std::string media;
597  ::tgbot::types::Ptr<std::string> caption;
598  ParseMode parseMode;
599  FileSource fileSource;
600 
601  private:
602  std::string what;
603  };
604 
605  struct InputMediaPhoto : public InputMedia {
606  public:
607  std::string toString() const override;
608  };
609 
610  struct InputMediaVideo : public InputMedia {
611  public:
612  std::string toString() const override;
613 
614  ::tgbot::types::Ptr<std::string> thumb;
615  int width;
616  int height;
617  int duration;
618  bool supportsStreaming : 1;
619  };
620 
621  struct InputMediaDocument : public InputMedia {
622  public:
623  std::string toString() const override;
624  ::tgbot::types::Ptr<std::string> thumb;
625  };
626 
627  struct InputMediaAnimation : public InputMedia {
628  public:
629  std::string toString() const override;
630  ::tgbot::types::Ptr<std::string> thumb;
631 
632  int width;
633  int height;
634  int duration;
635  };
636 
637  struct InputMediaAudio : public InputMedia {
638  public:
639  std::string toString() const override;
640 
641  ::tgbot::types::Ptr<std::string> thumb;
642  ::tgbot::types::Ptr<std::string> performer;
643  ::tgbot::types::Ptr<std::string> title;
644  int duration;
645  };
646 
647  } // namespace types
648 
649  } // namespace methods
650 
651 } // namespace tgbot
652 
653 #endif
Definition: types.h:175
This struct contains parameters for sendInvoice method.
Definition: types.h:543
FileSource
Choose if filename should be treated as file_id or uploaded via multipart.
Definition: types.h:70
ChatAction
What the bot is doing.
Definition: types.h:53
Definition: types.h:128
CallbackGame
(note) according to telegram API documentation, this is only a placeholder, currently using this has ...
Definition: types.h:520
Main tgbot namespace.
Definition: bot.h:13
CallbackGame callbackGame
check tgbot::types::CallbackGame for further infos
Definition: types.h:121
Definition: types.h:495
ParseMode
Parsing mode to be used.
Definition: types.h:46
trait as local upload via multipart
Definition: types.h:576
Definition: types.h:82