From dc38df06940c762cfcf1d562ddad7fbe14ae8a5d Mon Sep 17 00:00:00 2001 From: vvaltman Date: Tue, 26 Aug 2014 20:30:30 +0400 Subject: [PATCH] Updated test lua script --- main.c | 4 ++-- test.lua | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 8767804..6d21fe9 100644 --- a/main.c +++ b/main.c @@ -418,7 +418,7 @@ void args_parse (int argc, char **argv) { "B" #endif #ifdef USE_LUA - "s" + "s:" #endif )) != -1) { @@ -475,7 +475,7 @@ void args_parse (int argc, char **argv) { break; #ifdef USE_LUA case 's': - lua_file = tstrdup (optarg); + lua_file = strdup (optarg); break; #endif case 'W': diff --git a/test.lua b/test.lua index 90a3de5..4393f19 100644 --- a/test.lua +++ b/test.lua @@ -40,7 +40,17 @@ end print ("HI, this is lua script") +function ok_cb(extra, success, result) + if success then + print ("SUCCESS!\n") + end +end +function my_set_chat_photo (extra, success, file) + if success then + chat_set_photo (extra, file, ok_cb, false) + end +end function on_msg_receive (msg) if started == 0 then @@ -49,6 +59,10 @@ function on_msg_receive (msg) if msg.out then return end + + if msg.media == 'photo' and msg.to.type == 'chat' then + load_photo (msg.id, my_set_chat_photo, msg.to.print_name) + end if (msg.text == 'ping') then if (msg.to.id == our_id) then print ('sending pong to ' .. tostring (msg.from.print_name)) @@ -75,16 +89,16 @@ function on_our_id (id) our_id = id end -function on_secret_chat_created (peer) - --vardump (peer) -end - -function on_user_update (user) +function on_user_update (user, what) --vardump (user) end -function on_chat_update (user) - --vardump (user) +function on_chat_update (chat, what) + --vardump (chat) +end + +function on_secret_chat_update (schat, what) + --vardump (schat) end function on_get_difference_end ()