@@ -646,63 +646,63 @@ void do_dialog_list (int arg_num, struct arg args[], struct in_ev *ev) {
646
646
}
647
647
648
648
void do_send_photo (int arg_num , struct arg args [], struct in_ev * ev ) {
649
- assert (arg_num = = 2 );
649
+ assert (arg_num > = 2 );
650
650
if (ev ) { ev -> refcnt ++ ; }
651
- tgl_do_send_document (TLS , -1 , args [0 ].P -> id , args [1 ].str , 0 , print_msg_success_gw , ev );
651
+ tgl_do_send_document (TLS , -1 , args [0 ].P -> id , args [1 ].str , 0 , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
652
652
}
653
653
654
654
void do_send_file (int arg_num , struct arg args [], struct in_ev * ev ) {
655
- assert (arg_num = = 2 );
655
+ assert (arg_num > = 2 );
656
656
if (ev ) { ev -> refcnt ++ ; }
657
- tgl_do_send_document (TLS , -2 , args [0 ].P -> id , args [1 ].str , 0 , print_msg_success_gw , ev );
657
+ tgl_do_send_document (TLS , -2 , args [0 ].P -> id , args [1 ].str , 0 , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
658
658
}
659
659
660
660
void do_send_audio (int arg_num , struct arg args [], struct in_ev * ev ) {
661
- assert (arg_num = = 2 );
661
+ assert (arg_num > = 2 );
662
662
if (ev ) { ev -> refcnt ++ ; }
663
- tgl_do_send_document (TLS , FLAG_DOCUMENT_AUDIO , args [0 ].P -> id , args [1 ].str , 0 , print_msg_success_gw , ev );
663
+ tgl_do_send_document (TLS , FLAG_DOCUMENT_AUDIO , args [0 ].P -> id , args [1 ].str , 0 , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
664
664
}
665
665
666
666
void do_send_video (int arg_num , struct arg args [], struct in_ev * ev ) {
667
- assert (arg_num = = 2 );
667
+ assert (arg_num > = 2 );
668
668
if (ev ) { ev -> refcnt ++ ; }
669
- tgl_do_send_document (TLS , FLAG_DOCUMENT_VIDEO , args [0 ].P -> id , args [1 ].str , 0 , print_msg_success_gw , ev );
669
+ tgl_do_send_document (TLS , FLAG_DOCUMENT_VIDEO , args [0 ].P -> id , args [1 ].str , 0 , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
670
670
}
671
671
672
672
void do_send_document (int arg_num , struct arg args [], struct in_ev * ev ) {
673
- assert (arg_num = = 2 );
673
+ assert (arg_num > = 2 );
674
674
if (ev ) { ev -> refcnt ++ ; }
675
- tgl_do_send_document (TLS , 0 , args [0 ].P -> id , args [1 ].str , 0 , print_msg_success_gw , ev );
675
+ tgl_do_send_document (TLS , 0 , args [0 ].P -> id , args [1 ].str , 0 , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
676
676
}
677
677
678
678
void do_reply_photo (int arg_num , struct arg args [], struct in_ev * ev ) {
679
- assert (arg_num = = 2 );
679
+ assert (arg_num > = 2 );
680
680
if (ev ) { ev -> refcnt ++ ; }
681
- tgl_do_reply_document (TLS , -1 , args [0 ].num , args [2 ].str , print_msg_success_gw , ev );
681
+ tgl_do_reply_document (TLS , -1 , args [0 ].num , args [1 ]. str , arg_num == 2 ? NULL : args [ 2 ].str , print_msg_success_gw , ev );
682
682
}
683
683
684
684
void do_reply_file (int arg_num , struct arg args [], struct in_ev * ev ) {
685
- assert (arg_num = = 2 );
685
+ assert (arg_num > = 2 );
686
686
if (ev ) { ev -> refcnt ++ ; }
687
- tgl_do_reply_document (TLS , -2 , args [0 ].num , args [1 ].str , print_msg_success_gw , ev );
687
+ tgl_do_reply_document (TLS , -2 , args [0 ].num , args [1 ].str , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
688
688
}
689
689
690
690
void do_reply_audio (int arg_num , struct arg args [], struct in_ev * ev ) {
691
- assert (arg_num = = 2 );
691
+ assert (arg_num > = 2 );
692
692
if (ev ) { ev -> refcnt ++ ; }
693
- tgl_do_reply_document (TLS , FLAG_DOCUMENT_AUDIO , args [0 ].num , args [1 ].str , print_msg_success_gw , ev );
693
+ tgl_do_reply_document (TLS , FLAG_DOCUMENT_AUDIO , args [0 ].num , args [1 ].str , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
694
694
}
695
695
696
696
void do_reply_video (int arg_num , struct arg args [], struct in_ev * ev ) {
697
- assert (arg_num = = 2 );
697
+ assert (arg_num > = 2 );
698
698
if (ev ) { ev -> refcnt ++ ; }
699
- tgl_do_reply_document (TLS , FLAG_DOCUMENT_VIDEO , args [0 ].num , args [1 ].str , print_msg_success_gw , ev );
699
+ tgl_do_reply_document (TLS , FLAG_DOCUMENT_VIDEO , args [0 ].num , args [1 ].str , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
700
700
}
701
701
702
702
void do_reply_document (int arg_num , struct arg args [], struct in_ev * ev ) {
703
- assert (arg_num = = 2 );
703
+ assert (arg_num > = 2 );
704
704
if (ev ) { ev -> refcnt ++ ; }
705
- tgl_do_reply_document (TLS , 0 , args [0 ].num , args [1 ].str , print_msg_success_gw , ev );
705
+ tgl_do_reply_document (TLS , 0 , args [0 ].num , args [1 ].str , arg_num == 2 ? NULL : args [ 2 ]. str , print_msg_success_gw , ev );
706
706
}
707
707
708
708
void do_send_text (int arg_num , struct arg args [], struct in_ev * ev ) {
@@ -1285,28 +1285,28 @@ struct command commands[] = {
1285
1285
{"rename_chat" , {ca_chat , ca_string_end , ca_none }, do_rename_chat , "rename_chat <chat> <new name>\tRenames chat" },
1286
1286
{"rename_contact" , {ca_user , ca_string , ca_string , ca_none }, do_rename_contact , "rename_contact <user> <first name> <last name>\tRenames contact" },
1287
1287
{"reply" , {ca_number , ca_string_end , ca_none }, do_reply , "msg <msg-id> <text>\tSends text reply to message" },
1288
- {"reply_audio" , {ca_number , ca_file_name_end , ca_none }, do_send_audio , "reply_audio <msg-id> <file>\tSends audio to peer" },
1288
+ {"reply_audio" , {ca_number , ca_file_name , ca_none }, do_send_audio , "reply_audio <msg-id> <file>\tSends audio to peer" },
1289
1289
{"reply_contact" , {ca_number , ca_string , ca_string , ca_string , ca_none }, do_reply_contact , "reply_contact <msg-id> <phone> <first-name> <last-name>\tSends contact (not necessary telegram user)" },
1290
- {"reply_document" , {ca_number , ca_file_name_end , ca_none }, do_reply_document , "reply_document <msg-id> <file>\tSends document to peer" },
1291
- {"reply_file" , {ca_number , ca_file_name_end , ca_none }, do_reply_file , "reply_file <msg-id> <file>\tSends document to peer" },
1290
+ {"reply_document" , {ca_number , ca_file_name , ca_none }, do_reply_document , "reply_document <msg-id> <file>\tSends document to peer" },
1291
+ {"reply_file" , {ca_number , ca_file_name , ca_none }, do_reply_file , "reply_file <msg-id> <file>\tSends document to peer" },
1292
1292
{"reply_location" , {ca_number , ca_double , ca_double , ca_none }, do_reply_location , "reply_location <msg-id> <latitude> <longitude>\tSends geo location" },
1293
- {"reply_photo" , {ca_number , ca_file_name_end , ca_none }, do_reply_photo , "reply_photo <msg-id> <file>\tSends photo to peer" },
1293
+ {"reply_photo" , {ca_number , ca_file_name , ca_string_end | ca_optional , ca_none }, do_reply_photo , "reply_photo <msg-id> <file> [caption] \tSends photo to peer" },
1294
1294
//{"reply_text", {ca_number, ca_file_name_end, ca_none}, do_reply_text, "reply_text <msg-id> <file>\tSends contents of text file as plain text message"},
1295
- {"reply_video" , {ca_number , ca_file_name_end , ca_none }, do_reply_video , "reply_video <msg-id> <file>\tSends video to peer" },
1295
+ {"reply_video" , {ca_number , ca_file_name , ca_none }, do_reply_video , "reply_video <msg-id> <file>\tSends video to peer" },
1296
1296
// {"restore_msg", {ca_number, ca_none}, do_restore_msg, "restore_msg <msg-id>\tRestores message. Only available shortly (one hour?) after deletion"},
1297
1297
{"safe_quit" , {ca_none }, do_safe_quit , "safe_quit\tWaits for all queries to end, then quits" },
1298
1298
{"search" , {ca_peer | ca_optional , ca_number | ca_optional , ca_number | ca_optional , ca_number | ca_optional , ca_number | ca_optional , ca_string_end }, do_search , "search [peer] [limit] [from] [to] [offset] pattern\tSearch for pattern in messages from date from to date to (unixtime) in messages with peer (if peer not present, in all messages)" },
1299
1299
{"secret_chat_rekey" , { ca_secret_chat , ca_none }, do_secret_chat_rekey , "generate new key for active secret chat" },
1300
- {"send_audio" , {ca_peer , ca_file_name_end , ca_none }, do_send_audio , "send_audio <peer> <file>\tSends audio to peer" },
1300
+ {"send_audio" , {ca_peer , ca_file_name , ca_none }, do_send_audio , "send_audio <peer> <file>\tSends audio to peer" },
1301
1301
{"send_contact" , {ca_peer , ca_string , ca_string , ca_string , ca_none }, do_send_contact , "send_contact <peer> <phone> <first-name> <last-name>\tSends contact (not necessary telegram user)" },
1302
- {"send_document" , {ca_peer , ca_file_name_end , ca_none }, do_send_document , "send_document <peer> <file>\tSends document to peer" },
1303
- {"send_file" , {ca_peer , ca_file_name_end , ca_none }, do_send_file , "send_file <peer> <file>\tSends document to peer" },
1302
+ {"send_document" , {ca_peer , ca_file_name , ca_none }, do_send_document , "send_document <peer> <file>\tSends document to peer" },
1303
+ {"send_file" , {ca_peer , ca_file_name , ca_none }, do_send_file , "send_file <peer> <file>\tSends document to peer" },
1304
1304
{"send_location" , {ca_peer , ca_double , ca_double , ca_none }, do_send_location , "send_location <peer> <latitude> <longitude>\tSends geo location" },
1305
- {"send_photo" , {ca_peer , ca_file_name_end , ca_none }, do_send_photo , "send_photo <peer> <file>\tSends photo to peer" },
1305
+ {"send_photo" , {ca_peer , ca_file_name , ca_string_end | ca_optional , ca_none }, do_send_photo , "send_photo <peer> <file> [caption] \tSends photo to peer" },
1306
1306
{"send_text" , {ca_peer , ca_file_name_end , ca_none }, do_send_text , "send_text <peer> <file>\tSends contents of text file as plain text message" },
1307
1307
{"send_typing" , {ca_peer , ca_none }, do_send_typing , "send_typing <peer>\tSends typing notification" },
1308
1308
{"send_typing_abort" , {ca_peer , ca_none }, do_send_typing_abort , "send_typing <peer>\tSends typing notification abort" },
1309
- {"send_video" , {ca_peer , ca_file_name_end , ca_none }, do_send_video , "send_video <peer> <file>\tSends video to peer" },
1309
+ {"send_video" , {ca_peer , ca_file_name , ca_string | ca_optional , ca_none }, do_send_video , "send_video <peer> <file> [caption] \tSends video to peer" },
1310
1310
{"set" , {ca_string , ca_number , ca_none }, do_set , "set <param> <value>\tSets value of param. Currently available: log_level, debug_verbosity, alarm, msg_num" },
1311
1311
{"set_password" , {ca_string | ca_optional , ca_none }, do_set_password , "set_password <hint>\tSets password" },
1312
1312
{"set_profile_name" , {ca_string , ca_string , ca_none }, do_set_profile_name , "set_profile_name <first-name> <last-name>\tSets profile name." },
@@ -2676,6 +2676,9 @@ void print_media (struct in_ev *ev, struct tgl_message_media *M) {
2676
2676
} else {
2677
2677
mprintf (ev , "[photo]" );
2678
2678
}
2679
+ if (M -> caption ) {
2680
+ mprintf (ev , " %s" , M -> caption );
2681
+ }
2679
2682
return ;
2680
2683
case tgl_message_media_document :
2681
2684
mprintf (ev , "[" );
@@ -2722,6 +2725,10 @@ void print_media (struct in_ev *ev, struct tgl_message_media *M) {
2722
2725
}
2723
2726
2724
2727
mprintf (ev , "]" );
2728
+
2729
+ if (M -> caption ) {
2730
+ mprintf (ev , " %s" , M -> caption );
2731
+ }
2725
2732
2726
2733
return ;
2727
2734
case tgl_message_media_document_encr :
0 commit comments