From 5da1506e213b129996656c785a92b29caae76de8 Mon Sep 17 00:00:00 2001 From: vvaltman Date: Fri, 24 Apr 2015 16:19:13 +0300 Subject: [PATCH] some small fixes. new tgl --- interface.c | 19 +++++++++++++++---- lua-tg.c | 4 ++-- tgl | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/interface.c b/interface.c index a9c83a9..86fb4d3 100644 --- a/interface.c +++ b/interface.c @@ -693,9 +693,20 @@ void do_user_info (int arg_num, struct arg args[], struct in_ev *ev) { } void do_fwd (int arg_num, struct arg args[], struct in_ev *ev) { - assert (arg_num == 2); + assert (arg_num >= 2); if (ev) { ev->refcnt ++; } - tgl_do_forward_message (TLS, args[0].P->id, args[1].num, print_msg_success_gw, ev); + assert (arg_num <= 1000); + if (arg_num == 2) { + tgl_do_forward_message (TLS, args[0].P->id, args[1].num, print_msg_success_gw, ev); + } else { + static int list[1000]; + int i; + for (i = 0; i < arg_num - 1; i++) { + list[i] = args[i + 1].num; + } + tgl_do_forward_messages (TLS, args[0].P->id, arg_num - 1, list, print_msg_list_success_gw, ev); + } + } void do_fwd_media (int arg_num, struct arg args[], struct in_ev *ev) { @@ -998,7 +1009,7 @@ void do_create_group_chat (int arg_num, struct arg args[], struct in_ev *ev) { void do_chat_set_photo (int arg_num, struct arg args[], struct in_ev *ev) { assert (arg_num == 2); if (ev) { ev->refcnt ++; } - tgl_do_set_chat_photo (TLS, args[0].P->id, args[1].str, print_msg_success_gw, ev); + tgl_do_set_chat_photo (TLS, args[0].P->id, args[1].str, print_success_gw, ev); } void do_set_profile_photo (int arg_num, struct arg args[], struct in_ev *ev) { @@ -1168,7 +1179,7 @@ struct command commands[] = { {"delete_msg", {ca_number, ca_none}, do_delete_msg, "delete_msg \tDeletes message"}, {"dialog_list", {ca_number | ca_optional, ca_number | ca_optional, ca_none}, do_dialog_list, "dialog_list [limit=100] [offset=0]\tList of last conversations"}, {"export_card", {ca_none}, do_export_card, "export_card\tPrints card that can be imported by another user with import_card method"}, - {"fwd", {ca_peer, ca_number, ca_none}, do_fwd, "fwd \tForwards message to peer. Forward to secret chats is forbidden"}, + {"fwd", {ca_peer, ca_number, ca_period, ca_none}, do_fwd, "fwd +\tForwards message to peer. Forward to secret chats is forbidden"}, {"fwd_media", {ca_peer, ca_number, ca_none}, do_fwd_media, "fwd \tForwards message media to peer. Forward to secret chats is forbidden. Result slightly differs from fwd"}, {"help", {ca_none}, do_help, "help\tPrints this help"}, {"history", {ca_peer, ca_number | ca_optional, ca_number | ca_optional, ca_none}, do_history, "history [limit] [offset]\tPrints messages with this peer (most recent message lower). Also marks messages as read"}, diff --git a/lua-tg.c b/lua-tg.c index 8cd0ad6..5fb4afb 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -642,7 +642,7 @@ void lua_msg_cb (struct tgl_state *TLSR, void *cb_extra, int success, struct tgl lua_pushnumber (luaState, success); - if (success) { + if (success && M && (M->flags & TGLMF_CREATED)) { push_message (M); } else { lua_pushboolean (luaState, 0); @@ -924,7 +924,7 @@ void lua_do_all (void) { p += 3; break; case lq_chat_set_photo: - tgl_do_set_chat_photo (TLS, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_msg_cb, lua_ptr[p]); + tgl_do_set_chat_photo (TLS, ((tgl_peer_t *)lua_ptr[p + 1])->id, lua_ptr[p + 2], lua_empty_cb, lua_ptr[p]); free (lua_ptr[p + 2]); p += 3; break; diff --git a/tgl b/tgl index a068ca8..a48066b 160000 --- a/tgl +++ b/tgl @@ -1 +1 @@ -Subproject commit a068ca863717541a9db2bb4fd9fd668500cfb4b9 +Subproject commit a48066bb6dbfedb74ddbe302c19b5e9ef856fffb