Skip to content

Commit 20435fa

Browse files
author
vvaltman
committed
fixes
1 parent f144d3f commit 20435fa

File tree

3 files changed

+65
-12
lines changed

3 files changed

+65
-12
lines changed

‎interface.c

+59-6
Original file line numberDiff line numberDiff line change
@@ -647,31 +647,61 @@ void do_dialog_list (int arg_num, struct arg args[], struct in_ev *ev) {
647647
void do_send_photo (int arg_num, struct arg args[], struct in_ev *ev) {
648648
assert (arg_num == 2);
649649
if (ev) { ev->refcnt ++; }
650-
tgl_do_send_document (TLS, -1, args[0].P->id, args[1].str, print_msg_success_gw, ev);
650+
tgl_do_send_document (TLS, -1, args[0].P->id, args[1].str, 0, print_msg_success_gw, ev);
651651
}
652652

653653
void do_send_file (int arg_num, struct arg args[], struct in_ev *ev) {
654654
assert (arg_num == 2);
655655
if (ev) { ev->refcnt ++; }
656-
tgl_do_send_document (TLS, -2, args[0].P->id, args[1].str, print_msg_success_gw, ev);
656+
tgl_do_send_document (TLS, -2, args[0].P->id, args[1].str, 0, print_msg_success_gw, ev);
657657
}
658658

659659
void do_send_audio (int arg_num, struct arg args[], struct in_ev *ev) {
660660
assert (arg_num == 2);
661661
if (ev) { ev->refcnt ++; }
662-
tgl_do_send_document (TLS, FLAG_DOCUMENT_AUDIO, args[0].P->id, args[1].str, print_msg_success_gw, ev);
662+
tgl_do_send_document (TLS, FLAG_DOCUMENT_AUDIO, args[0].P->id, args[1].str, 0, print_msg_success_gw, ev);
663663
}
664664

665665
void do_send_video (int arg_num, struct arg args[], struct in_ev *ev) {
666666
assert (arg_num == 2);
667667
if (ev) { ev->refcnt ++; }
668-
tgl_do_send_document (TLS, FLAG_DOCUMENT_VIDEO, args[0].P->id, args[1].str, print_msg_success_gw, ev);
668+
tgl_do_send_document (TLS, FLAG_DOCUMENT_VIDEO, args[0].P->id, args[1].str, 0, print_msg_success_gw, ev);
669669
}
670670

671671
void do_send_document (int arg_num, struct arg args[], struct in_ev *ev) {
672672
assert (arg_num == 2);
673673
if (ev) { ev->refcnt ++; }
674-
tgl_do_send_document (TLS, 0, args[0].P->id, args[1].str, print_msg_success_gw, ev);
674+
tgl_do_send_document (TLS, 0, args[0].P->id, args[1].str, 0, print_msg_success_gw, ev);
675+
}
676+
677+
void do_reply_photo (int arg_num, struct arg args[], struct in_ev *ev) {
678+
assert (arg_num == 2);
679+
if (ev) { ev->refcnt ++; }
680+
tgl_do_reply_document (TLS, -1, args[0].num, args[2].str, print_msg_success_gw, ev);
681+
}
682+
683+
void do_reply_file (int arg_num, struct arg args[], struct in_ev *ev) {
684+
assert (arg_num == 2);
685+
if (ev) { ev->refcnt ++; }
686+
tgl_do_reply_document (TLS, -2, args[0].num, args[1].str, print_msg_success_gw, ev);
687+
}
688+
689+
void do_reply_audio (int arg_num, struct arg args[], struct in_ev *ev) {
690+
assert (arg_num == 2);
691+
if (ev) { ev->refcnt ++; }
692+
tgl_do_reply_document (TLS, FLAG_DOCUMENT_AUDIO, args[0].num, args[1].str, print_msg_success_gw, ev);
693+
}
694+
695+
void do_reply_video (int arg_num, struct arg args[], struct in_ev *ev) {
696+
assert (arg_num == 2);
697+
if (ev) { ev->refcnt ++; }
698+
tgl_do_reply_document (TLS, FLAG_DOCUMENT_VIDEO, args[0].num, args[1].str, print_msg_success_gw, ev);
699+
}
700+
701+
void do_reply_document (int arg_num, struct arg args[], struct in_ev *ev) {
702+
assert (arg_num == 2);
703+
if (ev) { ev->refcnt ++; }
704+
tgl_do_reply_document (TLS, 0, args[0].num, args[1].str, print_msg_success_gw, ev);
675705
}
676706

677707
void do_send_text (int arg_num, struct arg args[], struct in_ev *ev) {
@@ -1107,7 +1137,13 @@ void do_import_card (int arg_num, struct arg args[], struct in_ev *ev) {
11071137
void do_send_contact (int arg_num, struct arg args[], struct in_ev *ev) {
11081138
assert (arg_num == 4);
11091139
if (ev) { ev->refcnt ++; }
1110-
tgl_do_send_contact (TLS, args[0].P->id, args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), args[3].str, strlen (args[3].str), print_msg_gw, ev);
1140+
tgl_do_send_contact (TLS, args[0].P->id, args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), args[3].str, strlen (args[3].str), print_msg_success_gw, ev);
1141+
}
1142+
1143+
void do_reply_contact (int arg_num, struct arg args[], struct in_ev *ev) {
1144+
assert (arg_num == 4);
1145+
if (ev) { ev->refcnt ++; }
1146+
tgl_do_reply_contact (TLS, args[0].num, args[1].str, strlen (args[1].str), args[2].str, strlen (args[2].str), args[3].str, strlen (args[3].str), print_msg_success_gw, ev);
11111147
}
11121148

11131149
void do_main_session (int arg_num, struct arg args[], struct in_ev *ev) {
@@ -1174,6 +1210,12 @@ void do_send_location (int arg_num, struct arg args[], struct in_ev *ev) {
11741210
tgl_do_send_location (TLS, args[0].P->id, args[1].dval, args[2].dval, print_msg_success_gw, ev);
11751211
}
11761212

1213+
void do_reply_location (int arg_num, struct arg args[], struct in_ev *ev) {
1214+
assert (arg_num == 3);
1215+
if (ev) { ev->refcnt ++; }
1216+
tgl_do_reply_location (TLS, args[0].num, args[1].dval, args[2].dval, print_msg_success_gw, ev);
1217+
}
1218+
11771219

11781220
struct command commands[] = {
11791221
{"accept_secret_chat", {ca_secret_chat, ca_none}, do_accept_secret_chat, "accept_secret_chat <secret chat>\tAccepts secret chat. Only useful with -E option"},
@@ -1214,6 +1256,14 @@ struct command commands[] = {
12141256
{"rename_chat", {ca_chat, ca_string_end, ca_none}, do_rename_chat, "rename_chat <chat> <new name>\tRenames chat"},
12151257
{"rename_contact", {ca_user, ca_string, ca_string, ca_none}, do_rename_contact, "rename_contact <user> <first name> <last name>\tRenames contact"},
12161258
{"reply", {ca_number, ca_string_end, ca_none}, do_reply, "msg <msg-id> <text>\tSends text reply to message"},
1259+
{"reply_audio", {ca_number, ca_file_name_end, ca_none}, do_send_audio, "reply_audio <msg-id> <file>\tSends audio to peer"},
1260+
{"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)"},
1261+
{"reply_document", {ca_number, ca_file_name_end, ca_none}, do_reply_document, "reply_document <msg-id> <file>\tSends document to peer"},
1262+
{"reply_file", {ca_number, ca_file_name_end, ca_none}, do_reply_file, "reply_file <msg-id> <file>\tSends document to peer"},
1263+
{"reply_location", {ca_number, ca_double, ca_double, ca_none}, do_reply_location, "reply_location <msg-id> <latitude> <longitude>\tSends geo location"},
1264+
{"reply_photo", {ca_number, ca_file_name_end, ca_none}, do_reply_photo, "reply_photo <msg-id> <file>\tSends photo to peer"},
1265+
//{"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"},
1266+
{"reply_video", {ca_number, ca_file_name_end, ca_none}, do_reply_video, "reply_video <msg-id> <file>\tSends video to peer"},
12171267
// {"restore_msg", {ca_number, ca_none}, do_restore_msg, "restore_msg <msg-id>\tRestores message. Only available shortly (one hour?) after deletion"},
12181268
{"safe_quit", {ca_none}, do_safe_quit, "safe_quit\tWaits for all queries to end, then quits"},
12191269
{"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)"},
@@ -3025,6 +3075,9 @@ void print_message (struct in_ev *ev, struct tgl_message *M) {
30253075
if (M->reply_id) {
30263076
mprintf (ev, "[reply to %d] ", M->reply_id);
30273077
}
3078+
if (M->flags & TGLMF_MENTION) {
3079+
mprintf (ev, "[mention] ");
3080+
}
30283081
if (M->message && strlen (M->message)) {
30293082
mprintf (ev, "%s", M->message);
30303083
}

‎lua-tg.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -894,27 +894,27 @@ void lua_do_all (void) {
894894
p += 3;
895895
break;
896896
case lq_send_photo:
897-
tgl_do_send_document (TLS, -1, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]);
897+
tgl_do_send_document (TLS, -1, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], 0, lua_msg_cb, lua_ptr[p]);
898898
free (lua_ptr[p + 2]);
899899
p += 3;
900900
break;
901901
case lq_send_video:
902-
tgl_do_send_document (TLS, FLAG_DOCUMENT_VIDEO, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]);
902+
tgl_do_send_document (TLS, FLAG_DOCUMENT_VIDEO, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], 0, lua_msg_cb, lua_ptr[p]);
903903
free (lua_ptr[p + 2]);
904904
p += 3;
905905
break;
906906
case lq_send_audio:
907-
tgl_do_send_document (TLS, FLAG_DOCUMENT_AUDIO, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]);
907+
tgl_do_send_document (TLS, FLAG_DOCUMENT_AUDIO, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], 0, lua_msg_cb, lua_ptr[p]);
908908
free (lua_ptr[p + 2]);
909909
p += 3;
910910
break;
911911
case lq_send_document:
912-
tgl_do_send_document (TLS, 0, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]);
912+
tgl_do_send_document (TLS, 0, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], 0, lua_msg_cb, lua_ptr[p]);
913913
free (lua_ptr[p + 2]);
914914
p += 3;
915915
break;
916916
case lq_send_file:
917-
tgl_do_send_document (TLS, -2, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]);
917+
tgl_do_send_document (TLS, -2, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], 0, lua_msg_cb, lua_ptr[p]);
918918
free (lua_ptr[p + 2]);
919919
p += 3;
920920
break;

‎tgl

0 commit comments

Comments
 (0)