diff --git a/README.md b/README.md index 0818a6e..59580a8 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ If two or more peers have same name, number is appended to the name. (for * **chat_add_user** \ \ - add user to chat * **chat_del_user** \ \ - remove user from chat * **rename_chat** \ \ +* **create_group_chat** \ \ - creates a groupchat with user, use chat_add_user to add more users #### Search diff --git a/interface.c b/interface.c index a7b468c..4a70849 100644 --- a/interface.c +++ b/interface.c @@ -322,6 +322,7 @@ char *commands[] = { "chat_with_peer", "delete_msg", "restore_msg", + "create_group_chat", 0 }; int commands_flags[] = { @@ -371,6 +372,7 @@ int commands_flags[] = { 07, 072, 07, + 072, 07 }; @@ -888,6 +890,7 @@ void interpreter (char *line UU) { "mark_read - mark read all received messages with peer\n" "add_contact - tries to add contact to contact-list by phone\n" "create_secret_chat - creates secret chat with this user\n" + "create_group_chat - creates group chat with this user, add more users with chat_add_user \n" "rename_contact - tries to rename contact. If you have another device it will be a fight\n" "suggested_contacts - print info about contacts, you have max common friends\n" "visualize_key - prints visualization of encryption key. You should compare it to your partner's one\n" @@ -938,6 +941,15 @@ void interpreter (char *line UU) { } else if (IS_WORD ("create_secret_chat")) { GET_PEER; do_create_secret_chat (id); + } else if (IS_WORD ("create_group_chat")) { + GET_PEER; + int t; + char *s = next_token (&t); + if (!s) { + printf ("Empty chat topic\n"); + RET; + } + do_create_group_chat (id, s); } else if (IS_WORD ("suggested_contacts")) { do_get_suggested (); } else if (IS_WORD ("status_online")) { diff --git a/queries.c b/queries.c index 426a5d5..e7ad64e 100644 --- a/queries.c +++ b/queries.c @@ -2784,6 +2784,36 @@ void do_create_secret_chat (peer_id_t id) { } /* }}} */ +/* {{{ Create group chat */ +struct query_methods create_group_chat_methods = { + .on_answer = fwd_msg_on_answer +}; + +void do_create_group_chat (peer_id_t id, char *chat_topic) { + assert (get_peer_type (id) == PEER_USER); + peer_t *U = user_chat_get (id); + if (!U) { + rprintf ("Can not create chat with unknown user\n"); + return; + } + clear_packet (); + out_int (CODE_messages_create_chat); + out_int (CODE_vector); + out_int (1); // Number of users, currently we support only 1 user. + if (U && U->user.access_hash) { + out_int (CODE_input_user_foreign); + out_int (get_peer_id (id)); + out_long (U->user.access_hash); + } else { + out_int (CODE_input_user_contact); + out_int (get_peer_id (id)); + } + out_string (chat_topic); + send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &create_group_chat_methods, 0); +} +/* }}} */ + + /* {{{ Delete msg */ int delete_msg_on_answer (struct query *q UU) { diff --git a/queries.h b/queries.h index 17c1e74..afcc64e 100644 --- a/queries.h +++ b/queries.h @@ -84,6 +84,7 @@ void do_rename_chat (peer_id_t id, char *name); void do_load_encr_video (struct encr_video *V, int next); void do_create_encr_chat_request (int user_id); void do_create_secret_chat (peer_id_t id); +void do_create_group_chat (peer_id_t id, char *chat_topic); void do_get_suggested (void); struct photo;