Skip to content

Commit c61c8ba

Browse files
author
V V
committed
support for layer 42
1 parent 5d29294 commit c61c8ba

File tree

4 files changed

+58
-9
lines changed

4 files changed

+58
-9
lines changed

‎interface.c

+39-4
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ void do_help (struct command *command, int arg_num, struct arg args[], struct in
712712
}
713713
}
714714

715+
void do_get_terms_of_service (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
716+
assert (!arg_num);
717+
if (ev) { ev->refcnt ++; }
718+
tgl_do_get_terms_of_service (TLS, print_string_gw, ev);
719+
}
720+
715721
void do_stats (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
716722
assert (!arg_num);
717723
static char stat_buf[1 << 15];
@@ -1141,6 +1147,13 @@ void do_channel_get_admins (struct command *command, int arg_num, struct arg arg
11411147
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);
11421148
}
11431149

1150+
void do_chat_upgrade (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
1151+
assert (arg_num == 1);
1152+
if (ev) { ev->refcnt ++; }
1153+
tgl_do_upgrade_group (TLS, args[0].peer_id, print_success_gw, ev);
1154+
}
1155+
1156+
11441157
/* }}} */
11451158

11461159
/* {{{ WORKING WITH USERS */
@@ -1633,6 +1646,7 @@ struct command commands[MAX_COMMANDS_SIZE] = {
16331646
{"chat_del_user", {ca_chat, ca_user, ca_none}, do_chat_del_user, "chat_del_user <chat> <user>\tDeletes user from chat", NULL},
16341647
{"chat_info", {ca_chat, ca_none}, do_chat_info, "chat_info <chat>\tPrints info about chat (id, members, admin, etc.)", NULL},
16351648
{"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},
1649+
{"chat_upgrade", {ca_chat, ca_none}, do_chat_upgrade, "chat_upgrade <chat>\tUpgrades chat to megagroup", NULL},
16361650
{"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},
16371651
{"clear", {ca_none}, do_clear, "clear\tClears all data and exits. For debug.", NULL},
16381652
{"contact_list", {ca_none}, do_contact_list, "contact_list\tPrints contact list", NULL},
@@ -1648,6 +1662,7 @@ struct command commands[MAX_COMMANDS_SIZE] = {
16481662
{"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},
16491663
{"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},
16501664
{"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},
1665+
{"get_terms_of_service", {ca_none}, do_get_terms_of_service, "get_terms_of_service\tPrints telegram's terms of service", NULL},
16511666
{"get_message", {ca_msg_id, ca_none}, do_get_message, "get_message <msg-id>\tGet message by id", NULL},
16521667
{"get_self", {ca_none}, do_get_self, "get_self \tGet our user info", NULL},
16531668
{"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
25772592
mpush_color (ev, COLOR_YELLOW);
25782593
mprintf (ev, "Channel ");
25792594
if (U->flags & TGLCHF_OFFICIAL) {
2580-
mprintf (ev, "(official) ");
2595+
mprintf (ev, "[verified] ");
2596+
}
2597+
if (U->flags & TGLCHF_BROADCAST) {
2598+
mprintf (ev, "[broadcast] ");
2599+
}
2600+
if (U->flags & TGLCHF_MEGAGROUP) {
2601+
mprintf (ev, "[megagroup] ");
2602+
}
2603+
if (U->flags & TGLCHF_DEACTIVATED) {
2604+
mprintf (ev, "[deactivated] ");
25812605
}
25822606
print_channel_name (ev, U->id, U);
25832607
if (C->username) {
@@ -4071,9 +4095,14 @@ void print_service_message (struct in_ev *ev, struct tgl_message *M) {
40714095
case tgl_message_action_chat_delete_photo:
40724096
mprintf (ev, " deleted photo\n");
40734097
break;
4074-
case tgl_message_action_chat_add_user:
4075-
mprintf (ev, " added user ");
4076-
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)));
4098+
case tgl_message_action_chat_add_users:
4099+
mprintf (ev, " added users:");
4100+
{
4101+
int i;
4102+
for (i = 0; i < M->action.user_num; i++) {
4103+
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])));
4104+
}
4105+
}
40774106
mprintf (ev, "\n");
40784107
break;
40794108
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) {
41294158
case tgl_message_action_channel_create:
41304159
mprintf (ev, " created channel %s\n", M->action.title);
41314160
break;
4161+
case tgl_message_action_migrated_to:
4162+
mprintf (ev, " migrated to channel\n");
4163+
break;
4164+
case tgl_message_action_migrated_from:
4165+
mprintf (ev, " migrated from group '%s'\n", M->action.title);
4166+
break;
41324167
}
41334168
mpop_color (ev);
41344169
//print_end ();

‎json-tg.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ json_t *json_pack_service (struct tgl_message *M) {
341341
case tgl_message_action_chat_delete_photo:
342342
assert (json_object_set (res, "type", json_string ("chat_delete_photo")) >= 0);
343343
break;
344-
case tgl_message_action_chat_add_user:
344+
case tgl_message_action_chat_add_users:
345345
assert (json_object_set (res, "type", json_string ("chat_add_user")) >= 0);
346-
assert (json_object_set (res, "user", json_pack_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.user))) >= 0);
346+
assert (json_object_set (res, "user", json_pack_peer (tgl_set_peer_id (TGL_PEER_USER, M->action.users[0]))) >= 0);
347347
break;
348348
case tgl_message_action_chat_add_user_by_link:
349349
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) {
402402
assert (json_object_set (res, "type", json_string ("channel_created")) >= 0);
403403
assert (json_object_set (res, "title", json_string (M->action.title)) >= 0);
404404
break;
405+
case tgl_message_action_migrated_to:
406+
assert (json_object_set (res, "type", json_string ("migrated_to")) >= 0);
407+
break;
408+
case tgl_message_action_migrated_from:
409+
assert (json_object_set (res, "type", json_string ("migrated_from")) >= 0);
410+
break;
405411
default:
406412
assert (json_object_set (res, "type", json_string ("???")) >= 0);
407413
break;

‎lua-tg.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,12 @@ void push_service (struct tgl_message *M) {
364364
lua_newtable (luaState);
365365
lua_add_string_field ("type", "chat_delete_photo");
366366
break;
367-
case tgl_message_action_chat_add_user:
367+
case tgl_message_action_chat_add_users:
368368
lua_newtable (luaState);
369369
lua_add_string_field ("type", "chat_add_user");
370370

371371
lua_pushstring (luaState, "user");
372-
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)));
372+
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])));
373373
lua_settable (luaState, -3);
374374
break;
375375
case tgl_message_action_chat_add_user_by_link:
@@ -450,6 +450,14 @@ void push_service (struct tgl_message *M) {
450450
lua_add_string_field ("type", "channel_created");
451451
lua_add_string_field ("title", M->action.title);
452452
break;
453+
case tgl_message_action_migrated_to:
454+
lua_newtable (luaState);
455+
lua_add_string_field ("type", "migrated_to");
456+
break;
457+
case tgl_message_action_migrated_from:
458+
lua_newtable (luaState);
459+
lua_add_string_field ("type", "migrated_from");
460+
break;
453461
default:
454462
lua_pushstring (luaState, "???");
455463
break;

0 commit comments

Comments
 (0)