From 101a6fd7d0832026fd06a00fbe32fa89195657a5 Mon Sep 17 00:00:00 2001 From: Vysheng Date: Tue, 9 Sep 2014 17:27:43 +0400 Subject: [PATCH] status function to lua --- README-LUA | 3 +++ lua-tg.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README-LUA b/README-LUA index dbb7be8..7c2853a 100644 --- a/README-LUA +++ b/README-LUA @@ -71,5 +71,8 @@ Function_list (arguments are listed aside from cb_function and cb_extra, : delete_msg (msg) restore_msg (number) + status_online () + status_offline () + Also, you have function postpone (cb_function, cb_extra, timeout). It will call your cb_function in specified number of seconds (number of seconds may be double). diff --git a/lua-tg.c b/lua-tg.c index 31d6800..8b07daa 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -488,7 +488,9 @@ enum lua_query_type { lq_delete_msg, lq_restore_msg, lq_accept_secret_chat, - lq_send_contact + lq_send_contact, + lq_status_online, + lq_status_offline }; struct lua_query_extra { @@ -1030,6 +1032,14 @@ void lua_do_all (void) { free (s3); p += 5; break; + case lq_status_online: + tgl_do_update_status (1, lua_empty_cb, lua_ptr[p]); + p ++; + break; + case lq_status_offline: + tgl_do_update_status (0, lua_empty_cb, lua_ptr[p]); + p ++; + break; /* lq_delete_msg, lq_restore_msg, @@ -1109,6 +1119,8 @@ struct lua_function functions[] = { {"restore_msg", lq_restore_msg, { lfp_positive_number, lfp_none }}, {"accept_secret_chat", lq_accept_secret_chat, { lfp_secret_chat, lfp_none }}, {"send_contact", lq_send_contact, { lfp_peer, lfp_string, lfp_string, lfp_string, lfp_none }}, + {"status_online", lq_status_online, { lfp_none }}, + {"status_offline", lq_status_offline, { lfp_none }}, { 0, 0, { lfp_none}} };