Telebot  4.7.0
Library for Telegram bot API
telebot-core.h
1 /*
2  * telebot
3  *
4  * Copyright (c) 2015 Elmurod Talipov.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef __TELEBOT_CORE_API_H__
20 #define __TELEBOT_CORE_API_H__
21 
22 #include <stdbool.h>
23 #include <pthread.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
50 typedef struct telebot_core_handler {
51  char *token;
52  char *proxy_addr;
53  char *proxy_auth;
55 
59 typedef struct telebot_core_response {
60  size_t size;
61  char *data;
63 
76 
88 
98  const char *auth);
99 
108 
129  int limit, int timeout, const char *allowed_updates,
130  telebot_core_response_t *response);
131 
152  const char *certificate, int max_connections, const char *allowed_updates,
153  telebot_core_response_t *response);
154 
162  telebot_core_response_t *response);
163 
171  telebot_core_response_t *response);
172 
180  telebot_core_response_t *response);
181 
201  long long int chat_id, const char *text, const char *parse_mode,
202  bool disable_web_page_preview, bool disable_notification, int reply_to_message_id,
203  const char *reply_markup, telebot_core_response_t *response);
204 
220  long long int chat_id, long long int from_chat_id, bool disable_notification,
221  int message_id, telebot_core_response_t *response);
222 
245  long long int chat_id, const char *photo, bool is_file, const char *caption,
246  const char *parse_mode, bool disable_notification, int reply_to_message_id,
247  const char *reply_markup, telebot_core_response_t *response);
248 
283  long long int chat_id, const char *audio, bool is_file, const char *caption,
284  const char *parse_mode, int duration, const char *performer, const char *title,
285  const char *thumb, bool disable_notification, int reply_to_message_id,
286  const char *reply_markup, telebot_core_response_t *response);
287 
313  long long int chat_id, const char *document, bool is_file, const char *thumb,
314  const char *caption, const char *parse_mode, bool disable_notification,
315  int reply_to_message_id, const char *reply_markup,
316  telebot_core_response_t *response);
317 
348  long long int chat_id, const char *video, bool is_file, int duration,
349  int width, int height, const char *thumb, const char *caption,
350  const char *parse_mode, bool supports_streaming, bool disable_notification,
351  int reply_to_message_id, const char *reply_markup,
352  telebot_core_response_t *response);
353 
381  long long int chat_id, const char *animation, bool is_file, int duration,
382  int width, int height, const char *thumb, const char *caption,
383  const char *parse_mode, bool disable_notification, int reply_to_message_id,
384  const char *reply_markup, telebot_core_response_t *response);
385 
409  long long int chat_id, const char *voice, bool is_file, const char *caption,
410  const char *parse_mode, int duration, bool disable_notification,
411  int reply_to_message_id, const char *reply_markup,
412  telebot_core_response_t *response);
413 
439  long long int chat_id, char *video_note, bool is_file, int duration, int length,
440  const char *thumb, bool disable_notification, int reply_to_message_id,
441  const char *reply_markup, telebot_core_response_t *response);
442 
462  long long int chat_id, float latitude, float longitude, int live_period,
463  bool disable_notification, int reply_to_message_id, const char *reply_markup,
464  telebot_core_response_t *response);
465 
485  long long int chat_id, int message_id, const char *inline_message_id,
486  float latitude, float longitude, const char *reply_markup,
487  telebot_core_response_t *response);
488 
505  long long int chat_id, int message_id, char *inline_message_id,
506  const char *reply_markup, telebot_core_response_t *response);
507 
530  long long int chat_id, float latitude, float longitude, const char *title,
531  const char *address, const char *foursquare_id, const char *foursquare_type,
532  bool disable_notification, int reply_to_message_id, const char *reply_markup,
533  telebot_core_response_t *response);
534 
555  long long int chat_id, const char *phone_number, const char *first_name,
556  const char *last_name, const char *vcard, bool disable_notification,
557  int reply_to_message_id, const char *reply_markup,
558  telebot_core_response_t *response);
559 
587  long long int chat_id, const char *question, const char *options,
588  bool is_anonymous, const char *type, bool allows_multiple_answers,
589  int correct_option_id, bool is_closed, bool disable_notification,
590  int reply_to_message_id, const char *reply_markup,
591  telebot_core_response_t *response);
592 
609  long long int chat_id, bool disable_notification,
610  int reply_to_message_id, const char *reply_markup,
611  telebot_core_response_t *response);
612 
635  long long int chat_id, const char *action, telebot_core_response_t *response);
636 
650  int user_id, int offset, int limit, telebot_core_response_t *response);
651 
662  telebot_core_response_t *response);
663 
676  const char *file_path, const char *out_file);
677 
696  long long int chat_id, int user_id, long until_date,
697  telebot_core_response_t *response);
698 
712  long long int chat_id, int user_id, telebot_core_response_t *response);
713 
747  long long int chat_id, int user_id, long until_date, bool can_send_messages,
748  bool can_send_media_messages, bool can_send_polls, bool can_send_other_messages,
749  bool can_add_web_page_previews, bool can_change_info, bool can_invite_users,
750  bool can_pin_messages, telebot_core_response_t *response);
751 
783  long long int chat_id, int user_id, bool can_change_info, bool can_post_messages,
784  bool can_edit_messages, bool can_delete_messages, bool can_invite_users,
785  bool can_restrict_members, bool can_pin_messages, bool can_promote_members,
786  telebot_core_response_t *response);
787 
803  long long int chat_id, int user_id, const char *custom_title,
804  telebot_core_response_t *response);
805 
835  long long int chat_id, bool can_send_messages, bool can_send_media_messages,
836  bool can_send_polls, bool can_send_other_messages, bool can_add_web_page_previews,
837  bool can_change_info, bool can_invite_users, bool can_pin_messages,
838  telebot_core_response_t *response);
839 
852  long long int chat_id, telebot_core_response_t *response);
853 
867  long long int chat_id, const char *photo, telebot_core_response_t *response);
868 
881  long long int chat_id, telebot_core_response_t *response);
882 
896  long long int chat_id, const char *title, telebot_core_response_t *response);
897 
911  long long int chat_id, const char *description,
912  telebot_core_response_t *response);
913 
930  long long int chat_id, int message_id, bool disable_notification,
931  telebot_core_response_t *response);
932 
945  long long int chat_id, telebot_core_response_t *response);
946 
957  long long int chat_id, telebot_core_response_t *response);
958 
970  long long int chat_id, telebot_core_response_t *response);
971 
985  long long int chat_id, telebot_core_response_t *response);
986 
997  long long int chat_id, telebot_core_response_t *response);
998 
1010  long long int chat_id, int user_id, telebot_core_response_t *response);
1011 
1027  long long int chat_id, const char *sticker_set_name,
1028  telebot_core_response_t *response);
1029 
1043  long long int chat_id, telebot_core_response_t *response);
1044 
1067  const char *callback_query_id, const char *text, bool show_alert,
1068  const char *url, int cache_time, telebot_core_response_t *response);
1069 
1080  const char *commands, telebot_core_response_t *response);
1081 
1090  telebot_core_response_t *response);
1091 
1111  long long int chat_id, int message_id, const char *inline_message_id,
1112  const char *text, const char *parse_mode, bool disable_web_page_preview,
1113  const char *reply_markup, telebot_core_response_t *response);
1114 
1131  long long int chat_id, int message_id, const char *inline_message_id,
1132  const char *caption, const char *parse_mode, const char *reply_markup,
1133  telebot_core_response_t *response);
1134 
1152  long long int chat_id, int message_id, const char *inline_message_id,
1153  const char *reply_markup, telebot_core_response_t *response);
1154 
1171  long long int chat_id, int message_id, const char *reply_markup,
1172  telebot_core_response_t *response);
1173 
1174 
1193  long long int chat_id, int message_id, telebot_core_response_t *response);
1194 
1195 
1201 
1206 #ifdef __cplusplus
1207 }
1208 #endif
1209 
1210 #endif /* __TELEBOT_CORE_API_H__ */
telebot_error_e
Enumerations of error code for telebot programming interface.
Definition: telebot-common.h:45
telebot_error_e telebot_core_send_message(telebot_core_handler_t *core_h, long long int chat_id, const char *text, const char *parse_mode, bool disable_web_page_preview, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send text messages.
telebot_error_e telebot_core_export_chat_invite_link(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Generate a new invite link for a chat; any previously generated link is revoked. The bot must be an a...
telebot_error_e telebot_core_get_chat(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Get up to date information about the chat (current name of the user for one-on-one conversations...
telebot_error_e telebot_core_send_poll(telebot_core_handler_t *core_h, long long int chat_id, const char *question, const char *options, bool is_anonymous, const char *type, bool allows_multiple_answers, int correct_option_id, bool is_closed, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send a native poll.
telebot_error_e telebot_core_edit_message_text(telebot_core_handler_t *core_h, long long int chat_id, int message_id, const char *inline_message_id, const char *text, const char *parse_mode, bool disable_web_page_preview, const char *reply_markup, telebot_core_response_t *response)
Edit text and game messages sent by the bot or via the bot (for inline bots).
telebot_error_e telebot_core_get_user_profile_photos(telebot_core_handler_t *core_h, int user_id, int offset, int limit, telebot_core_response_t *response)
Get user profile pictures object.
telebot_error_e telebot_core_get_me(telebot_core_handler_t *core_h, telebot_core_response_t *response)
Get basic information about the bot.
This object represents a core telebot handler.
Definition: telebot-core.h:50
telebot_error_e telebot_core_stop_poll(telebot_core_handler_t *core_h, long long int chat_id, int message_id, const char *reply_markup, telebot_core_response_t *response)
Stop a poll which was sent by the bot.
telebot_error_e telebot_core_get_proxy(telebot_core_handler_t *core_h, char **addr)
Get currently used proxy address.
telebot_error_e telebot_core_set_chat_title(telebot_core_handler_t *core_h, long long int chat_id, const char *title, telebot_core_response_t *response)
Change the title of a chat. Titles can&#39;t be changed for private chats. The bot must be an administrat...
telebot_error_e telebot_core_edit_message_caption(telebot_core_handler_t *core_h, long long int chat_id, int message_id, const char *inline_message_id, const char *caption, const char *parse_mode, const char *reply_markup, telebot_core_response_t *response)
Edit captions of messages sent by the bot or via the bot (for inline bots).
telebot_error_e telebot_core_answer_callback_query(telebot_core_handler_t *core_h, const char *callback_query_id, const char *text, bool show_alert, const char *url, int cache_time, telebot_core_response_t *response)
Send answers to callback queries sent from inline keyboards. The answer will be displayed to the user...
telebot_error_e telebot_core_get_chat_admins(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Get a list of administrators in a chat. Response contains an array of objects that contains informati...
telebot_error_e telebot_core_set_my_commands(telebot_core_handler_t *core_h, const char *commands, telebot_core_response_t *response)
Change the list of the bot&#39;s commands.
void telebot_core_put_response(telebot_core_response_t *response)
Release response data obtained with telebot core methods.
telebot_error_e telebot_core_get_webhook_info(telebot_core_handler_t *core_h, telebot_core_response_t *response)
Get current webhook status.
telebot_error_e telebot_core_stop_message_live_location(telebot_core_handler_t *core_h, long long int chat_id, int message_id, char *inline_message_id, const char *reply_markup, telebot_core_response_t *response)
Stop updating a live location message sent by the bot or via the bot (for inline bots) before live_pe...
telebot_error_e telebot_core_destroy(telebot_core_handler_t **core_h)
Final function to use telebot core APIs.
telebot_error_e telebot_core_create(telebot_core_handler_t **core_h, const char *token)
Start function to use telebot core APIs.
telebot_error_e telebot_core_send_audio(telebot_core_handler_t *core_h, long long int chat_id, const char *audio, bool is_file, const char *caption, const char *parse_mode, int duration, const char *performer, const char *title, const char *thumb, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send audio files. if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. Bots can currently send audio files of up to 50 MB in size. For backward compatibility, when the fields title and performer are both empty and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. For this to work, the audio must be in an .ogg file encoded with OPUS. For sending voice messages, use the telegram_core_send_voice() function instead.
telebot_error_e telebot_core_delete_chat_photo(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Delete a chat photo. Photos can&#39;t be changed for private chats. The bot must be an administrator in t...
telebot_error_e telebot_core_download_file(telebot_core_handler_t *core_h, const char *file_path, const char *out_file)
Download file using file_path obtained with telebot_core_get_file(). It is guaranteed that the link w...
telebot_error_e telebot_core_send_photo(telebot_core_handler_t *core_h, long long int chat_id, const char *photo, bool is_file, const char *caption, const char *parse_mode, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send photos.
telebot_error_e telebot_core_get_chat_members_count(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Get the number of members in a chat.
char * token
Definition: telebot-core.h:51
telebot_error_e telebot_core_restrict_chat_member(telebot_core_handler_t *core_h, long long int chat_id, int user_id, long until_date, bool can_send_messages, bool can_send_media_messages, bool can_send_polls, bool can_send_other_messages, bool can_add_web_page_previews, bool can_change_info, bool can_invite_users, bool can_pin_messages, telebot_core_response_t *response)
Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work ...
telebot_error_e telebot_core_unpin_chat_message(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this t...
telebot_error_e telebot_core_set_proxy(telebot_core_handler_t *core_h, const char *addr, const char *auth)
Set proxy address to use telebot behind proxy.
telebot_error_e telebot_core_send_voice(telebot_core_handler_t *core_h, long long int chat_id, const char *voice, bool is_file, const char *caption, const char *parse_mode, int duration, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send audio files, if you want Telegram clients to display the file as a playable voice message...
telebot_error_e telebot_core_forward_message(telebot_core_handler_t *core_h, long long int chat_id, long long int from_chat_id, bool disable_notification, int message_id, telebot_core_response_t *response)
Forward messages of any kind.
struct telebot_core_response telebot_core_response_t
This object represents a telegram bot response.
telebot_error_e telebot_core_unban_chat_member(telebot_core_handler_t *core_h, long long int chat_id, int user_id, telebot_core_response_t *response)
Unban a previously kicked user in a supergroup or channel. The user will not return to the group or c...
This object represents a telegram bot response.
Definition: telebot-core.h:59
telebot_error_e telebot_core_edit_message_reply_markup(telebot_core_handler_t *core_h, long long int chat_id, int message_id, const char *inline_message_id, const char *reply_markup, telebot_core_response_t *response)
Edit only the reply markup of messages sent by the bot or via the bot (for inline bots)...
telebot_error_e telebot_core_send_video_note(telebot_core_handler_t *core_h, long long int chat_id, char *video_note, bool is_file, int duration, int length, const char *thumb, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send video messages. As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minut...
telebot_error_e telebot_core_set_chat_photo(telebot_core_handler_t *core_h, long long int chat_id, const char *photo, telebot_core_response_t *response)
Set a new profile photo for the chat. Photos can&#39;t be changed for private chats. The bot must be an a...
telebot_error_e telebot_core_send_venue(telebot_core_handler_t *core_h, long long int chat_id, float latitude, float longitude, const char *title, const char *address, const char *foursquare_id, const char *foursquare_type, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send information about a venue.
telebot_error_e telebot_core_send_location(telebot_core_handler_t *core_h, long long int chat_id, float latitude, float longitude, int live_period, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send point on the map.
telebot_error_e telebot_core_kick_chat_member(telebot_core_handler_t *core_h, long long int chat_id, int user_id, long until_date, telebot_core_response_t *response)
Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels...
telebot_error_e telebot_core_get_file(telebot_core_handler_t *core_h, const char *file_id, telebot_core_response_t *response)
Get basic info about a file and prepare it for downloading. For the moment, bots can download files o...
telebot_error_e telebot_core_set_chat_description(telebot_core_handler_t *core_h, long long int chat_id, const char *description, telebot_core_response_t *response)
Change the description of a supergroup or a channel. The bot must be an administrator in the chat for...
telebot_error_e telebot_core_leave_chat(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Leave a group, supergroup or channel.
telebot_error_e telebot_core_delete_message(telebot_core_handler_t *core_h, long long int chat_id, int message_id, telebot_core_response_t *response)
Delete a message, including service messages, with the following limitations:
telebot_error_e telebot_core_get_updates(telebot_core_handler_t *core_h, int offset, int limit, int timeout, const char *allowed_updates, telebot_core_response_t *response)
Receive incoming updates (long polling). It will not work if an outgoing webhook is set up...
telebot_error_e telebot_core_send_chat_action(telebot_core_handler_t *core_h, long long int chat_id, const char *action, telebot_core_response_t *response)
Tell the user that something is happening on the bot&#39;s side. The status is set for 5 seconds or less ...
char * data
Definition: telebot-core.h:61
telebot_error_e telebot_core_send_dice(telebot_core_handler_t *core_h, long long int chat_id, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send a dice, which will have a random value from 1 to 6.
struct telebot_core_handler telebot_core_handler_t
This object represents a core telebot handler.
size_t size
Definition: telebot-core.h:60
telebot_error_e telebot_core_set_chat_permissions(telebot_core_handler_t *core_h, long long int chat_id, bool can_send_messages, bool can_send_media_messages, bool can_send_polls, bool can_send_other_messages, bool can_add_web_page_previews, bool can_change_info, bool can_invite_users, bool can_pin_messages, telebot_core_response_t *response)
Set default chat permissions for all members. The bot must be an administrator in the group or a supe...
telebot_error_e telebot_core_promote_chat_member(telebot_core_handler_t *core_h, long long int chat_id, int user_id, bool can_change_info, bool can_post_messages, bool can_edit_messages, bool can_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages, bool can_promote_members, telebot_core_response_t *response)
Promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat f...
telebot_error_e telebot_core_send_video(telebot_core_handler_t *core_h, long long int chat_id, const char *video, bool is_file, int duration, int width, int height, const char *thumb, const char *caption, const char *parse_mode, bool supports_streaming, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send video files, Telegram clients support mp4 videos (other formats may be sent as Document)...
telebot_error_e telebot_core_send_document(telebot_core_handler_t *core_h, long long int chat_id, const char *document, bool is_file, const char *thumb, const char *caption, const char *parse_mode, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send general files.
telebot_error_e telebot_core_delete_webhook(telebot_core_handler_t *core_h, telebot_core_response_t *response)
Remove webhook integration if you decide to switch back to getUpdates.
telebot_error_e telebot_core_send_contact(telebot_core_handler_t *core_h, long long int chat_id, const char *phone_number, const char *first_name, const char *last_name, const char *vcard, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send phone contacts.
telebot_error_e telebot_core_send_animation(telebot_core_handler_t *core_h, long long int chat_id, const char *animation, bool is_file, int duration, int width, int height, const char *thumb, const char *caption, const char *parse_mode, bool disable_notification, int reply_to_message_id, const char *reply_markup, telebot_core_response_t *response)
Send animation files (GIF or H.264/MPEG-4 AVC without sound).
telebot_error_e telebot_core_get_chat_member(telebot_core_handler_t *core_h, long long int chat_id, int user_id, telebot_core_response_t *response)
Get information about a member of a chat.
telebot_error_e telebot_core_pin_chat_message(telebot_core_handler_t *core_h, long long int chat_id, int message_id, bool disable_notification, telebot_core_response_t *response)
Pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to ...
telebot_error_e telebot_core_edit_message_live_location(telebot_core_handler_t *core_h, long long int chat_id, int message_id, const char *inline_message_id, float latitude, float longitude, const char *reply_markup, telebot_core_response_t *response)
Edit live location messages sent by the bot or via the bot (for inline bots). A location can be edite...
telebot_error_e telebot_core_set_chat_sticker_set(telebot_core_handler_t *core_h, long long int chat_id, const char *sticker_set_name, telebot_core_response_t *response)
Set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this t...
telebot_error_e telebot_core_get_my_commands(telebot_core_handler_t *core_h, telebot_core_response_t *response)
Get the current list of the bot&#39;s commands..
telebot_error_e telebot_core_delete_chat_sticker_set(telebot_core_handler_t *core_h, long long int chat_id, telebot_core_response_t *response)
Delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this t...
telebot_error_e telebot_core_set_chat_admin_custom_title(telebot_core_handler_t *core_h, long long int chat_id, int user_id, const char *custom_title, telebot_core_response_t *response)
Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for ...
telebot_error_e telebot_core_set_webhook(telebot_core_handler_t *core_h, const char *url, const char *certificate, int max_connections, const char *allowed_updates, telebot_core_response_t *response)
Specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for t...