|
86 | 86 | # include "json-tg.h"
|
87 | 87 | #endif
|
88 | 88 |
|
| 89 | +#include "tgl/mtproto-common.h" |
| 90 | +#include "auto/auto-store.h" |
| 91 | +#include "auto/auto-fetch-ds.h" |
| 92 | +#include "auto/auto-types.h" |
| 93 | +#include "auto/auto-free-ds.h" |
| 94 | + |
89 | 95 | #define ALLOW_MULT 1
|
90 | 96 | char *default_prompt = "> ";
|
91 | 97 |
|
@@ -127,14 +133,13 @@ extern int daemonize;
|
127 | 133 | extern struct tgl_state *TLS;
|
128 | 134 | int readline_deactivated;
|
129 | 135 |
|
| 136 | +void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) __attribute__ (( format (printf, 4, 5))); |
130 | 137 | void event_incoming (struct bufferevent *bev, short what, void *_arg);
|
131 | 138 |
|
132 | 139 | int is_same_word (const char *s, size_t l, const char *word) {
|
133 | 140 | return s && word && strlen (word) == l && !memcmp (s, word, l);
|
134 | 141 | }
|
135 | 142 |
|
136 |
| -void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) __attribute__ (( format (printf, 4, 5))); |
137 |
| - |
138 | 143 | static void skip_wspc (void) {
|
139 | 144 | while (*line_ptr && ((unsigned char)*line_ptr) <= ' ') {
|
140 | 145 | line_ptr ++;
|
@@ -746,7 +751,27 @@ void do_msg (struct command *command, int arg_num, struct arg args[], struct in_
|
746 | 751 | assert (arg_num == 2);
|
747 | 752 | if (ev) { ev->refcnt ++; }
|
748 | 753 | vlogprintf (E_DEBUG, "reply_id=%d, disable=%d\n", reply_id, disable_msg_preview);
|
749 |
| - tgl_do_send_message (TLS, args[0].P->id, ARG2STR(1), TGL_SEND_MSG_FLAG_REPLY(reply_id) | disable_msg_preview, print_msg_success_gw, ev); |
| 754 | + tgl_do_send_message (TLS, args[0].P->id, ARG2STR(1), TGL_SEND_MSG_FLAG_REPLY(reply_id) | disable_msg_preview, NULL, print_msg_success_gw, ev); |
| 755 | +} |
| 756 | + |
| 757 | +void do_msg_kbd (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { |
| 758 | + assert (arg_num == 3); |
| 759 | + if (ev) { ev->refcnt ++; } |
| 760 | + |
| 761 | + clear_packet (); |
| 762 | + if (tglf_store_type (TLS, ARG2STR(1), TYPE_TO_PARAM (reply_markup)) < 0) { |
| 763 | + fail_interface (TLS, ev, ENOSYS, "can not parse reply markup"); |
| 764 | + return; |
| 765 | + } |
| 766 | + in_ptr = packet_buffer; |
| 767 | + in_end = packet_ptr; |
| 768 | + |
| 769 | + struct tl_ds_reply_markup *DS_RM = fetch_ds_type_reply_markup (TYPE_TO_PARAM (reply_markup)); |
| 770 | + assert (DS_RM); |
| 771 | + |
| 772 | + tgl_do_send_message (TLS, args[0].P->id, ARG2STR(2), TGL_SEND_MSG_FLAG_REPLY(reply_id) | disable_msg_preview, DS_RM, print_msg_success_gw, ev); |
| 773 | + |
| 774 | + free_ds_type_reply_markup (DS_RM, TYPE_TO_PARAM (reply_markup)); |
750 | 775 | }
|
751 | 776 |
|
752 | 777 | void do_reply (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
|
@@ -1392,6 +1417,7 @@ struct command commands[MAX_COMMANDS_SIZE] = {
|
1392 | 1417 | {"main_session", {ca_none}, do_main_session, "main_session\tSends updates to this connection (or terminal). Useful only with listening socket", NULL},
|
1393 | 1418 | {"mark_read", {ca_peer, ca_none}, do_mark_read, "mark_read <peer>\tMarks messages with peer as read", NULL},
|
1394 | 1419 | {"msg", {ca_peer, ca_msg_string_end, ca_none}, do_msg, "msg <peer> <text>\tSends text message to peer", NULL},
|
| 1420 | + {"msg_kbd", {ca_peer, ca_string, ca_msg_string_end, ca_none}, do_msg_kbd, "msg <peer> <kbd> <text>\tSends text message to peer with custom kbd", NULL}, |
1395 | 1421 | {"quit", {ca_none}, do_quit, "quit\tQuits immediately", NULL},
|
1396 | 1422 | {"rename_chat", {ca_chat, ca_string_end, ca_none}, do_rename_chat, "rename_chat <chat> <new name>\tRenames chat", NULL},
|
1397 | 1423 | {"rename_contact", {ca_user, ca_string, ca_string, ca_none}, do_rename_contact, "rename_contact <user> <first name> <last name>\tRenames contact", NULL},
|
@@ -1837,7 +1863,6 @@ void print_fail (struct in_ev *ev) {
|
1837 | 1863 | mprint_end (ev);
|
1838 | 1864 | }
|
1839 | 1865 |
|
1840 |
| -void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) __attribute__ (( format (printf, 4, 5))); |
1841 | 1866 | void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) {
|
1842 | 1867 | static char error[1001];
|
1843 | 1868 |
|
@@ -2299,7 +2324,7 @@ void interpreter_chat_mode (char *line) {
|
2299 | 2324 | return;
|
2300 | 2325 | }
|
2301 | 2326 | if (strlen (line) > 0) {
|
2302 |
| - tgl_do_send_message (TLS, chat_mode_id, line, strlen (line), 0, 0, 0); |
| 2327 | + tgl_do_send_message (TLS, chat_mode_id, line, strlen (line), 0, NULL, 0, 0); |
2303 | 2328 | }
|
2304 | 2329 | }
|
2305 | 2330 |
|
|
0 commit comments