Added send_contact function
This commit is contained in:
parent
ab5aa2b6ba
commit
7ce6dbbf0b
21
interface.c
21
interface.c
@ -377,6 +377,7 @@ struct command commands[] = {
|
||||
{"accept_secret_chat", {ca_secret_chat, ca_none}},
|
||||
{"export_card", {ca_none}},
|
||||
{"import_card", {ca_string, ca_none}},
|
||||
{"send_contact", {ca_peer, ca_string, ca_string, ca_string}},
|
||||
{0, {ca_none}}
|
||||
};
|
||||
|
||||
@ -1289,6 +1290,26 @@ void interpreter (char *line UU) {
|
||||
RET;
|
||||
}
|
||||
tgl_do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0, print_user_list_gw, 0);
|
||||
} else if (IS_WORD ("send_contact")) {
|
||||
GET_PEER;
|
||||
int phone_len, first_name_len, last_name_len;
|
||||
char *phone, *first_name, *last_name;
|
||||
phone = next_token (&phone_len);
|
||||
if (!phone) {
|
||||
printf ("No phone number found\n");
|
||||
RET;
|
||||
}
|
||||
first_name = next_token (&first_name_len);
|
||||
if (!first_name_len) {
|
||||
printf ("No first name found\n");
|
||||
RET;
|
||||
}
|
||||
last_name = next_token (&last_name_len);
|
||||
if (!last_name_len) {
|
||||
printf ("No last name found\n");
|
||||
RET;
|
||||
}
|
||||
tgl_do_send_contact (id, phone, phone_len, first_name, first_name_len, last_name, last_name_len, print_msg_gw, 0);
|
||||
} else if (IS_WORD ("rename_contact")) {
|
||||
GET_PEER_USER;
|
||||
tgl_peer_t *U = tgl_peer_get (id);
|
||||
|
14
lua-tg.c
14
lua-tg.c
@ -477,7 +477,8 @@ enum lua_query_type {
|
||||
lq_load_document_thumb,
|
||||
lq_delete_msg,
|
||||
lq_restore_msg,
|
||||
lq_accept_secret_chat
|
||||
lq_accept_secret_chat,
|
||||
lq_send_contact
|
||||
};
|
||||
|
||||
struct lua_query_extra {
|
||||
@ -1005,6 +1006,16 @@ void lua_do_all (void) {
|
||||
tgl_do_accept_encr_chat_request (lua_ptr[p + 1], lua_secret_chat_cb, lua_ptr[p]);
|
||||
p += 2;
|
||||
break;
|
||||
case lq_send_contact:
|
||||
s1 = lua_ptr[p + 2];
|
||||
s2 = lua_ptr[p + 3];
|
||||
s3 = lua_ptr[p + 4];
|
||||
tgl_do_send_contact (((tgl_peer_t *)lua_ptr[p + 1])->id, s1, strlen (s1), s2, strlen (s2), s3, strlen (s3), lua_msg_cb, lua_ptr[p]);
|
||||
free (s1);
|
||||
free (s2);
|
||||
free (s3);
|
||||
p += 5;
|
||||
break;
|
||||
/*
|
||||
lq_delete_msg,
|
||||
lq_restore_msg,
|
||||
@ -1082,6 +1093,7 @@ struct lua_function functions[] = {
|
||||
{"delete_msg", lq_delete_msg, { lfp_msg, lfp_none }},
|
||||
{"restore_msg", lq_restore_msg, { lfp_positive_number, lfp_none }},
|
||||
{"accept_secret_chat", lq_accept_secret_chat, { lfp_secret_chat, lfp_none }},
|
||||
{"send_contact", lq_send_contact, { lfp_peer, lfp_string, lfp_string, lfp_string, lfp_none }},
|
||||
{ 0, 0, { lfp_none}}
|
||||
};
|
||||
|
||||
|
53
queries.c
53
queries.c
@ -1829,6 +1829,29 @@ void tgl_do_forward_message (tgl_peer_id_t id, int n, void (*callback)(void *cal
|
||||
out_long (r);
|
||||
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
|
||||
}
|
||||
|
||||
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra) {
|
||||
if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) {
|
||||
if (callback) {
|
||||
((void (*)(void *, int, struct tgl_message *))callback) (callback_extra, 0, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
long long t;
|
||||
tglt_secure_random (&t, 8);
|
||||
vlogprintf (E_DEBUG, "t = %lld\n", t);
|
||||
|
||||
clear_packet ();
|
||||
out_int (CODE_messages_send_media);
|
||||
out_peer_id (id);
|
||||
out_int (CODE_input_media_contact);
|
||||
out_cstring (phone, phone_len);
|
||||
out_cstring (first_name, first_name_len);
|
||||
out_cstring (last_name, last_name_len);
|
||||
out_long (t);
|
||||
|
||||
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Rename chat */
|
||||
@ -2370,36 +2393,6 @@ static int add_contact_on_answer (struct query *q UU) {
|
||||
for (i = 0; i < n; i++) {
|
||||
UL[i] = tglf_fetch_alloc_user ();
|
||||
}
|
||||
/*for (i = 0; i < n ; i++) {
|
||||
struct tgl_user *U = tglf_fetch_alloc_user ();
|
||||
print_start ();
|
||||
push_color (COLOR_YELLOW);
|
||||
printf ("User #%d: ", tgl_get_peer_id (U->id));
|
||||
print_user_name (U->id, (tgl_peer_t *)U);
|
||||
push_color (COLOR_GREEN);
|
||||
printf (" (");
|
||||
printf ("%s", U->print_name);
|
||||
if (U->phone) {
|
||||
printf (" ");
|
||||
printf ("%s", U->phone);
|
||||
}
|
||||
printf (") ");
|
||||
pop_color ();
|
||||
if (U->status.online > 0) {
|
||||
printf ("online\n");
|
||||
} else {
|
||||
if (U->status.online < 0) {
|
||||
printf ("offline. Was online ");
|
||||
print_date_full (U->status.when);
|
||||
} else {
|
||||
printf ("offline permanent");
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
pop_color ();
|
||||
print_end ();
|
||||
|
||||
}*/
|
||||
|
||||
if (q->callback) {
|
||||
((void (*)(void *, int, int, struct tgl_user **))q->callback) (q->callback_extra, 1, n, UL);
|
||||
|
1
tgl.h
1
tgl.h
@ -278,6 +278,7 @@ void tgl_do_update_status (int online, void (*callback)(void *callback_extra, in
|
||||
void tgl_do_help_get_config_dc (struct tgl_dc *D, void (*callback)(void *, int), void *callback_extra);
|
||||
void tgl_do_export_card (void (*callback)(void *callback_extra, int success, int size, int *card), void *callback_extra);
|
||||
void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra);
|
||||
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
|
||||
|
||||
|
||||
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);
|
||||
|
Loading…
Reference in New Issue
Block a user