Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Supported text formatting in media captions.
Browse files Browse the repository at this point in the history
  • Loading branch information
h4child committed May 23, 2018
1 parent 402e39b commit c3896d1
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 61 deletions.
24 changes: 12 additions & 12 deletions include/framebot/framebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@

#define fstrlen(p) (p == NULL ? 0 : strlen(p))

#define STRING_NULL(p) (p == NULL ? "null":p)
#define STRING_NULL(p) (p == NULL ? "null": p)

#define UPDATE_ID_LAST(x, y) (x->update_id > y->update_id ? x->update_id : y->update_id)

Expand Down Expand Up @@ -303,37 +303,37 @@ Message * forward_message_chat (Bot * bot, long int chat_id, long int from_chat_
bool disable_notification, long int message_id);

/* sendphoto */
Message * send_photo(Bot * bot, char * chat_id, char * filename, char * caption,
Message * send_photo(Bot * bot, char * chat_id, char * filename, char * caption, char *parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup);
Message * send_photo_chat(Bot * bot, long int chat_id, char * filename, char * caption,
Message * send_photo_chat(Bot * bot, long int chat_id, char * filename, char * caption, char * parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup);

/* sendaudio */
Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption, long int duration,
Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption, char * parse_mode, long int duration,
char * performer, char * title, bool disable_notification, long int reply_to_message_id,
char * reply_markup);
Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * caption, long int duration,
Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * caption, char * parse_mode, long int duration,
char * performer, char * title, bool disable_notification, long int reply_to_message_id,
char * reply_markup);

/* senddocument */
Message * send_document(Bot * bot, char * chat_id, char * filename, char * caption,
Message * send_document(Bot * bot, char * chat_id, char * filename, char * caption, char * parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup);
Message * send_document_chat(Bot * bot, long int chat_id, char * filename, char * caption,
Message * send_document_chat(Bot * bot, long int chat_id, char * filename, char * caption, char * parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup);

/* sendvideo */
Message * send_video(Bot * bot, char * chat_id, char * video, long int duration, long int width,
long int height, char * caption, char *parse_mode, bool supports_streaming, bool disable_notification, long int reply_to_message_id,
long int height, char * caption, char *parse_mode, bool supports_streaming,bool disable_notification, long int reply_to_message_id,
char * reply_markup);
Message * send_video_chat(Bot * bot, long int chat_id, char * video, long int duration, long int width,
long int height, char * caption, char *parse_mode, bool supports_streaming, bool disable_notification, long int reply_to_message_id,
char * reply_markup);

/* sendvoice */
Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption, long int duration,
Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption, char * parse_mode, long int duration,
bool disable_notification, long int reply_to_message_id, char * reply_markup);
Message * send_voice_chat(Bot *bot, long int chat_id, char * filename, char * caption, long int duration,
Message * send_voice_chat(Bot *bot, long int chat_id, char * filename, char * caption, char * parse_mode, long int duration,
bool disable_notification, long int reply_to_message_id, char * reply_markup);

Message * send_video_note(Bot * bot, char * chat_id, char * filename, long int duration,
Expand Down Expand Up @@ -482,10 +482,10 @@ Message *edit_message_text_chat(Bot *bot, long int chat_id, long int message_id,
/* editMessageText */
Message *edit_message_caption(Bot *bot, char *chat_id,
long int message_id, char *inline_message_id, char *caption,
char *reply_markup);
char * parse_mode, char *reply_markup);
Message *edit_message_caption_chat(Bot *bot, long int chat_id,
long int message_id, char *inline_message_id, char *caption,
char *reply_markup);
char * parse_mode, char *reply_markup);

/* editMessageCaption */
Message *edit_message_reply_markup(Bot *bot, char *chat_id, long int message_id,
Expand Down
4 changes: 4 additions & 0 deletions include/framebot/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct _sphoto{
char * chat_id;
char * filename;
char * caption;
char * parse_mode;
char * disable_notification;
char * reply_to_message_id;
char * reply_markup;
Expand All @@ -39,6 +40,7 @@ typedef struct _saudio{
char * chat_id;
char * filename;
char * caption;
char * parse_mode;
char * duration;
char * performer;
char * title;
Expand All @@ -52,6 +54,7 @@ typedef struct _sdocument{
char * chat_id;
char * filename;
char * caption;
char * parse_mode;
char * disable_notification;
char * reply_to_message_id;
char * reply_markup;
Expand All @@ -77,6 +80,7 @@ typedef struct _svoice{
char * chat_id;
char * filename;
char * caption;
char * parse_mode;
char * duration;
char * disable_notification;
char * reply_to_message_id;
Expand Down
44 changes: 27 additions & 17 deletions src/framebot.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ UserProfilePhotos * get_user_profile_photos_chat (Bot * bot, long user_id,
*
*/
Message * send_photo(Bot * bot, char * chat_id, char * filename,
char * caption, bool disable_notification,
char * caption, char *parse_mode, bool disable_notification,
long int reply_to_message_id, char * reply_markup){
Message * message;

Expand All @@ -879,6 +879,8 @@ Message * send_photo(Bot * bot, char * chat_id, char * filename,
* photos by file_id), 0-200 characters */
ifile.photo.caption = caption;

ifile.photo.parse_mode = PARSE_MODE(parse_mode);

/* Sends the message silently */
ifile.photo.disable_notification = DISABLE_NOTIFICATION(disable_notification);

Expand Down Expand Up @@ -914,15 +916,15 @@ Message * send_photo(Bot * bot, char * chat_id, char * filename,



Message * send_photo_chat(Bot * bot, long int chat_id, char * filename, char * caption,
Message * send_photo_chat(Bot * bot, long int chat_id, char * filename, char * caption, char *parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup){

Message * message;
char * cchat_id;

cchat_id = api_ltoa(chat_id);

message = send_photo(bot, cchat_id, filename, caption,
message = send_photo(bot, cchat_id, filename, caption, parse_mode,
disable_notification, reply_to_message_id,
REPLY_MARKUP(reply_markup));

Expand All @@ -936,7 +938,7 @@ Message * send_photo_chat(Bot * bot, long int chat_id, char * filename, char * c
* sendAudio
*
*/
Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption,
Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption, char *parse_mode,
long int duration, char * performer, char * title, bool disable_notification,
long int reply_to_message_id, char * reply_markup){

Expand All @@ -955,6 +957,8 @@ Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption,
/* Audio caption, 0-200 characters */
ifile.audio.caption = caption;

ifile.audio.caption = PARSE_MODE(parse_mode);

/* Duration of the audio in seconds */
ifile.audio.duration = DURATION(duration);

Expand Down Expand Up @@ -1000,7 +1004,7 @@ Message * send_audio(Bot *bot, char * chat_id, char * filename, char * caption,



Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * caption,
Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * caption, char *parse_mode,
long int duration, char * performer, char * title, bool disable_notification,
long int reply_to_message_id, char * reply_markup){

Expand All @@ -1009,9 +1013,9 @@ Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * c

cchat_id = api_ltoa(chat_id);

message = send_audio(bot, cchat_id, filename, caption, duration,
message = send_audio(bot, cchat_id, filename, caption, parse_mode, duration,
performer, title, disable_notification,
reply_to_message_id, REPLY_MARKUP(reply_markup));
reply_to_message_id, reply_markup);

free(cchat_id);

Expand All @@ -1023,7 +1027,7 @@ Message * send_audio_chat(Bot * bot, long int chat_id, char * filename, char * c
* sendDocument
*
*/
Message * send_document(Bot * bot, char * chat_id, char * filename, char * caption,
Message * send_document(Bot * bot, char * chat_id, char * filename, char * caption, char *parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup){

Message * message;
Expand All @@ -1042,6 +1046,8 @@ Message * send_document(Bot * bot, char * chat_id, char * filename, char * capti
* Documents by file_id), 0-200 characters */
ifile.document.caption = caption;

ifile.document.parse_mode = PARSE_MODE(parse_mode);

/* Sends the message silently */
ifile.document.disable_notification = DISABLE_NOTIFICATION(disable_notification);

Expand Down Expand Up @@ -1073,15 +1079,15 @@ Message * send_document(Bot * bot, char * chat_id, char * filename, char * capti



Message * send_document_chat(Bot * bot, long int chat_id, char * filename, char * caption,
Message * send_document_chat(Bot * bot, long int chat_id, char * filename, char * caption, char *parse_mode,
bool disable_notification, long int reply_to_message_id, char * reply_markup){

Message * message;
char * cchat_id;

cchat_id = api_ltoa(chat_id);

message = send_document(bot, cchat_id, filename, caption,
message = send_document(bot, cchat_id, filename, caption, parse_mode,
disable_notification, reply_to_message_id,
REPLY_MARKUP(reply_markup));

Expand Down Expand Up @@ -1122,6 +1128,8 @@ Message * send_video(Bot * bot, char * chat_id, char * filename, long int durati
/* Audio caption, 0-200 characters */
ifile.video.caption = caption;

ifile.video.caption = PARSE_MODE(parse_mode);

/* parse mode MODE_HTML or MODE_MARKDOWN */
ifile.video.parse_mode = PARSE_MODE(parse_mode);

Expand Down Expand Up @@ -1185,7 +1193,7 @@ Message * send_video_chat(Bot * bot, long int chat_id, char * filename, long int
* sendVoice
*
*/
Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption,
Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption, char *parse_mode,
long int duration, bool disable_notification, long int reply_to_message_id,
char * reply_markup){
Message * message;
Expand All @@ -1203,6 +1211,8 @@ Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption,
/* Audio caption, 0-200 characters */
ifile.voice.caption = caption;

ifile.voice.parse_mode = PARSE_MODE(parse_mode);

/* Duration of the audio in seconds */
ifile.voice.duration = DURATION(duration);

Expand Down Expand Up @@ -1241,15 +1251,15 @@ Message * send_voice(Bot *bot, char * chat_id, char * filename, char * caption,



Message * send_voice_chat(Bot *bot, long int chat_id, char * filename, char * caption, long int duration,
Message * send_voice_chat(Bot *bot, long int chat_id, char * filename, char * caption, char *parse_mode, long int duration,
bool disable_notification, long int reply_to_message_id, char * reply_markup){

Message * message;
char * cchat_id;

cchat_id = api_ltoa(chat_id);

message = send_voice(bot, cchat_id, filename, caption, duration,
message = send_voice(bot, cchat_id, filename, caption, parse_mode, duration,
disable_notification,reply_to_message_id,
REPLY_MARKUP(reply_markup));

Expand Down Expand Up @@ -1707,12 +1717,12 @@ Message *edit_message_text_chat(Bot *bot, long int chat_id, long int message_id,
*/
Message *edit_message_caption(Bot *bot, char *chat_id,
long int message_id, char *inline_message_id, char *caption,
char *reply_markup){
char *parse_mode, char *reply_markup){
Message *message;
refjson *s_json;

s_json = generic_method_call(bot->token, API_editMessageCaption, chat_id,
message_id, inline_message_id, caption, REPLY_MARKUP(reply_markup));
message_id, inline_message_id, caption, parse_mode, REPLY_MARKUP(reply_markup));

if(!s_json)
return NULL;
Expand All @@ -1726,14 +1736,14 @@ Message *edit_message_caption(Bot *bot, char *chat_id,

Message *edit_message_caption_chat(Bot *bot, long int chat_id,
long int message_id, char *inline_message_id, char *caption,
char *reply_markup){
char *parse_mode, char *reply_markup){
Message *message;
char *cchat_id;

cchat_id = api_ltoa(chat_id);

message = edit_message_caption(bot, cchat_id, message_id,
inline_message_id, caption, reply_markup);
inline_message_id, caption, PARSE_MODE(parse_mode), reply_markup);

free(cchat_id);

Expand Down

0 comments on commit c3896d1

Please sign in to comment.