Updated test lua script

This commit is contained in:
vvaltman 2014-08-26 20:30:30 +04:00
parent 8625cb2247
commit dc38df0694
2 changed files with 23 additions and 9 deletions

4
main.c
View File

@ -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':

View File

@ -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 ()