Commit c61c8ba9 authored by V V's avatar V V

support for layer 42

parent 5d29294c
...@@ -712,6 +712,12 @@ void do_help (struct command *command, int arg_num, struct arg args[], struct in ...@@ -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) { void do_stats (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
assert (!arg_num); assert (!arg_num);
static char stat_buf[1 << 15]; static char stat_buf[1 << 15];
...@@ -1141,6 +1147,13 @@ void do_channel_get_admins (struct command *command, int arg_num, struct arg arg ...@@ -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); 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 */ /* {{{ WORKING WITH USERS */
...@@ -1633,6 +1646,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { ...@@ -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 <chat> <user>\tDeletes user from chat", NULL}, {"chat_del_user", {ca_chat, ca_user, ca_none}, do_chat_del_user, "chat_del_user <chat> <user>\tDeletes user from chat", NULL},
{"chat_info", {ca_chat, ca_none}, do_chat_info, "chat_info <chat>\tPrints info about chat (id, members, admin, etc.)", NULL}, {"chat_info", {ca_chat, ca_none}, do_chat_info, "chat_info <chat>\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 <chat> <filename>\tSets chat photo. Photo will be cropped to square", NULL}, {"chat_set_photo", {ca_chat, ca_file_name_end, ca_none}, do_chat_set_photo, "chat_set_photo <chat> <filename>\tSets chat photo. Photo will be cropped to square", NULL},
{"chat_upgrade", {ca_chat, ca_none}, do_chat_upgrade, "chat_upgrade <chat>\tUpgrades chat to megagroup", NULL},
{"chat_with_peer", {ca_peer, ca_none}, do_chat_with_peer, "chat_with_peer <peer>\tInterface option. All input will be treated as messages to this peer. Type /quit to end this mode", NULL}, {"chat_with_peer", {ca_peer, ca_none}, do_chat_with_peer, "chat_with_peer <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}, {"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}, {"contact_list", {ca_none}, do_contact_list, "contact_list\tPrints contact list", NULL},
...@@ -1648,6 +1662,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { ...@@ -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}, {"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 <peer> <msg-id>+\tForwards message to peer. Forward to secret chats is forbidden", NULL}, {"fwd", {ca_peer, ca_msg_id, ca_period, ca_none}, do_fwd, "fwd <peer> <msg-id>+\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 <peer> <msg-id>\tForwards message media to peer. Forward to secret chats is forbidden. Result slightly differs from fwd", NULL}, {"fwd_media", {ca_peer, ca_msg_id, ca_none}, do_fwd_media, "fwd_media <peer> <msg-id>\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 <msg-id>\tGet message by id", NULL}, {"get_message", {ca_msg_id, ca_none}, do_get_message, "get_message <msg-id>\tGet message by id", NULL},
{"get_self", {ca_none}, do_get_self, "get_self \tGet our user info", 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}, {"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 ...@@ -2577,7 +2592,16 @@ void print_channel_info_gw (struct tgl_state *TLSR, void *extra, int success, st
mpush_color (ev, COLOR_YELLOW); mpush_color (ev, COLOR_YELLOW);
mprintf (ev, "Channel "); mprintf (ev, "Channel ");
if (U->flags & TGLCHF_OFFICIAL) { 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); print_channel_name (ev, U->id, U);
if (C->username) { if (C->username) {
...@@ -4071,9 +4095,14 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) { ...@@ -4071,9 +4095,14 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) {
case tgl_message_action_chat_delete_photo: case tgl_message_action_chat_delete_photo:
mprintf (ev, " deleted photo\n"); mprintf (ev, " deleted photo\n");
break; break;
case tgl_message_action_chat_add_user: case tgl_message_action_chat_add_users:
mprintf (ev, " added user "); mprintf (ev, " added users:");
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))); {
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"); mprintf (ev, "\n");
break; break;
case tgl_message_action_chat_add_user_by_link: 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) { ...@@ -4129,6 +4158,12 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) {
case tgl_message_action_channel_create: case tgl_message_action_channel_create:
mprintf (ev, " created channel %s\n", M->action.title); mprintf (ev, " created channel %s\n", M->action.title);
break; 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); mpop_color (ev);
//print_end (); //print_end ();
......
...@@ -341,9 +341,9 @@ json_t *json_pack_service (struct tgl_message *M) { ...@@ -341,9 +341,9 @@ json_t *json_pack_service (struct tgl_message *M) {
case tgl_message_action_chat_delete_photo: case tgl_message_action_chat_delete_photo:
assert (json_object_set (res, "type", json_string ("chat_delete_photo")) >= 0); assert (json_object_set (res, "type", json_string ("chat_delete_photo")) >= 0);
break; 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, "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; break;
case tgl_message_action_chat_add_user_by_link: case tgl_message_action_chat_add_user_by_link:
assert (json_object_set (res, "type", json_string ("chat_add_user_link")) >= 0); 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) { ...@@ -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, "type", json_string ("channel_created")) >= 0);
assert (json_object_set (res, "title", json_string (M->action.title)) >= 0); assert (json_object_set (res, "title", json_string (M->action.title)) >= 0);
break; 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: default:
assert (json_object_set (res, "type", json_string ("???")) >= 0); assert (json_object_set (res, "type", json_string ("???")) >= 0);
break; break;
......
...@@ -364,12 +364,12 @@ void push_service (struct tgl_message *M) { ...@@ -364,12 +364,12 @@ void push_service (struct tgl_message *M) {
lua_newtable (luaState); lua_newtable (luaState);
lua_add_string_field ("type", "chat_delete_photo"); lua_add_string_field ("type", "chat_delete_photo");
break; break;
case tgl_message_action_chat_add_user: case tgl_message_action_chat_add_users:
lua_newtable (luaState); lua_newtable (luaState);
lua_add_string_field ("type", "chat_add_user"); lua_add_string_field ("type", "chat_add_user");
lua_pushstring (luaState, "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); lua_settable (luaState, -3);
break; break;
case tgl_message_action_chat_add_user_by_link: case tgl_message_action_chat_add_user_by_link:
...@@ -450,6 +450,14 @@ void push_service (struct tgl_message *M) { ...@@ -450,6 +450,14 @@ void push_service (struct tgl_message *M) {
lua_add_string_field ("type", "channel_created"); lua_add_string_field ("type", "channel_created");
lua_add_string_field ("title", M->action.title); lua_add_string_field ("title", M->action.title);
break; 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: default:
lua_pushstring (luaState, "???"); lua_pushstring (luaState, "???");
break; break;
......
Subproject commit b64e63ebba02bb37d3eb811eed4f6cd43d7d946d Subproject commit bc8613899875589d7dd31e7f6de74cb5d4d4a8ae
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment