diff --git a/interface.c b/interface.c index 37ef2a4..9a66de2 100644 --- a/interface.c +++ b/interface.c @@ -712,6 +712,12 @@ void do_help (struct command *command, int arg_num, struct arg args[], struct in } } +void do_get_terms_of_service (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { + assert (!arg_num); + if (ev) { ev->refcnt ++; } + tgl_do_get_terms_of_service (TLS, print_string_gw, ev); +} + void do_stats (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { assert (!arg_num); static char stat_buf[1 << 15]; @@ -1141,6 +1147,13 @@ void do_channel_get_admins (struct command *command, int arg_num, struct arg arg tgl_do_channel_get_members (TLS, args[0].peer_id, args[1].num == NOT_FOUND ? 100 : args[1].num, args[2].num == NOT_FOUND ? 0 : args[2].num, 1, print_user_list_gw, ev); } +void do_chat_upgrade (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { + assert (arg_num == 1); + if (ev) { ev->refcnt ++; } + tgl_do_upgrade_group (TLS, args[0].peer_id, print_success_gw, ev); +} + + /* }}} */ /* {{{ WORKING WITH USERS */ @@ -1633,6 +1646,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { {"chat_del_user", {ca_chat, ca_user, ca_none}, do_chat_del_user, "chat_del_user \tDeletes user from chat", NULL}, {"chat_info", {ca_chat, ca_none}, do_chat_info, "chat_info \tPrints info about chat (id, members, admin, etc.)", NULL}, {"chat_set_photo", {ca_chat, ca_file_name_end, ca_none}, do_chat_set_photo, "chat_set_photo \tSets chat photo. Photo will be cropped to square", NULL}, + {"chat_upgrade", {ca_chat, ca_none}, do_chat_upgrade, "chat_upgrade \tUpgrades chat to megagroup", NULL}, {"chat_with_peer", {ca_peer, ca_none}, do_chat_with_peer, "chat_with_peer \tInterface option. All input will be treated as messages to this peer. Type /quit to end this mode", NULL}, {"clear", {ca_none}, do_clear, "clear\tClears all data and exits. For debug.", NULL}, {"contact_list", {ca_none}, do_contact_list, "contact_list\tPrints contact list", NULL}, @@ -1648,6 +1662,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { {"export_chat_link", {ca_chat, ca_none}, do_export_chat_link, "export_chat_link\tPrints chat link that can be used to join to chat", NULL}, {"fwd", {ca_peer, ca_msg_id, ca_period, ca_none}, do_fwd, "fwd +\tForwards message to peer. Forward to secret chats is forbidden", NULL}, {"fwd_media", {ca_peer, ca_msg_id, ca_none}, do_fwd_media, "fwd_media \tForwards message media to peer. Forward to secret chats is forbidden. Result slightly differs from fwd", NULL}, + {"get_terms_of_service", {ca_none}, do_get_terms_of_service, "get_terms_of_service\tPrints telegram's terms of service", NULL}, {"get_message", {ca_msg_id, ca_none}, do_get_message, "get_message \tGet message by id", NULL}, {"get_self", {ca_none}, do_get_self, "get_self \tGet our user info", NULL}, {"help", {ca_command | ca_optional, ca_none}, do_help, "help [command]\tPrints this help", NULL}, @@ -2577,7 +2592,16 @@ void print_channel_info_gw (struct tgl_state *TLSR, void *extra, int success, st mpush_color (ev, COLOR_YELLOW); mprintf (ev, "Channel "); if (U->flags & TGLCHF_OFFICIAL) { - mprintf (ev, "(official) "); + mprintf (ev, "[verified] "); + } + if (U->flags & TGLCHF_BROADCAST) { + mprintf (ev, "[broadcast] "); + } + if (U->flags & TGLCHF_MEGAGROUP) { + mprintf (ev, "[megagroup] "); + } + if (U->flags & TGLCHF_DEACTIVATED) { + mprintf (ev, "[deactivated] "); } print_channel_name (ev, U->id, U); if (C->username) { @@ -4071,9 +4095,14 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) { case tgl_message_action_chat_delete_photo: mprintf (ev, " deleted photo\n"); break; - case tgl_message_action_chat_add_user: - mprintf (ev, " added user "); - print_user_name (ev, tgl_set_peer_id (TGL_PEER_USER, M->action.user), tgl_peer_get (TLS, tgl_set_peer_id (TGL_PEER_USER, M->action.user))); + case tgl_message_action_chat_add_users: + mprintf (ev, " added users:"); + { + int i; + for (i = 0; i < M->action.user_num; i++) { + print_user_name (ev, tgl_set_peer_id (TGL_PEER_USER, M->action.users[i]), tgl_peer_get (TLS, tgl_set_peer_id (TGL_PEER_USER, M->action.users[i]))); + } + } mprintf (ev, "\n"); break; case tgl_message_action_chat_add_user_by_link: @@ -4129,6 +4158,12 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) { case tgl_message_action_channel_create: mprintf (ev, " created channel %s\n", M->action.title); break; + case tgl_message_action_migrated_to: + mprintf (ev, " migrated to channel\n"); + break; + case tgl_message_action_migrated_from: + mprintf (ev, " migrated from group '%s'\n", M->action.title); + break; } mpop_color (ev); //print_end (); diff --git a/json-tg.c b/json-tg.c index c9fc401..cdd42dd 100644 --- a/json-tg.c +++ b/json-tg.c @@ -341,9 +341,9 @@ json_t *json_pack_service (struct tgl_message *M) { case tgl_message_action_chat_delete_photo: assert (json_object_set (res, "type", json_string ("chat_delete_photo")) >= 0); break; - case tgl_message_action_chat_add_user: + case tgl_message_action_chat_add_users: assert (json_object_set (res, "type", json_string ("chat_add_user")) >= 0); - assert (json_object_set (res, "user", json_pack_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.user))) >= 0); + assert (json_object_set (res, "user", json_pack_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.users[0]))) >= 0); break; case tgl_message_action_chat_add_user_by_link: assert (json_object_set (res, "type", json_string ("chat_add_user_link")) >= 0); @@ -402,6 +402,12 @@ json_t *json_pack_service (struct tgl_message *M) { assert (json_object_set (res, "type", json_string ("channel_created")) >= 0); assert (json_object_set (res, "title", json_string (M->action.title)) >= 0); break; + case tgl_message_action_migrated_to: + assert (json_object_set (res, "type", json_string ("migrated_to")) >= 0); + break; + case tgl_message_action_migrated_from: + assert (json_object_set (res, "type", json_string ("migrated_from")) >= 0); + break; default: assert (json_object_set (res, "type", json_string ("???")) >= 0); break; diff --git a/lua-tg.c b/lua-tg.c index b0244d5..4746db0 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -364,12 +364,12 @@ void push_service (struct tgl_message *M) { lua_newtable (luaState); lua_add_string_field ("type", "chat_delete_photo"); break; - case tgl_message_action_chat_add_user: + case tgl_message_action_chat_add_users: lua_newtable (luaState); lua_add_string_field ("type", "chat_add_user"); lua_pushstring (luaState, "user"); - push_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.user), tgl_peer_get (TLS, tgl_set_peer_id (TGL_PEER_USER, M->action.user))); + push_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.users[0]), tgl_peer_get (TLS, tgl_set_peer_id (TGL_PEER_USER, M->action.users[0]))); lua_settable (luaState, -3); break; case tgl_message_action_chat_add_user_by_link: @@ -450,6 +450,14 @@ void push_service (struct tgl_message *M) { lua_add_string_field ("type", "channel_created"); lua_add_string_field ("title", M->action.title); break; + case tgl_message_action_migrated_to: + lua_newtable (luaState); + lua_add_string_field ("type", "migrated_to"); + break; + case tgl_message_action_migrated_from: + lua_newtable (luaState); + lua_add_string_field ("type", "migrated_from"); + break; default: lua_pushstring (luaState, "???"); break; diff --git a/tgl b/tgl index b64e63e..bc86138 160000 --- a/tgl +++ b/tgl @@ -1 +1 @@ -Subproject commit b64e63ebba02bb37d3eb811eed4f6cd43d7d946d +Subproject commit bc8613899875589d7dd31e7f6de74cb5d4d4a8ae