2014-01-11 19:43:56 -05:00
|
|
|
started = 0
|
|
|
|
our_id = 0
|
|
|
|
|
|
|
|
function vardump(value, depth, key)
|
|
|
|
local linePrefix = ""
|
|
|
|
local spaces = ""
|
|
|
|
|
|
|
|
if key ~= nil then
|
|
|
|
linePrefix = "["..key.."] = "
|
|
|
|
end
|
|
|
|
|
|
|
|
if depth == nil then
|
|
|
|
depth = 0
|
|
|
|
else
|
|
|
|
depth = depth + 1
|
|
|
|
for i=1, depth do spaces = spaces .. " " end
|
|
|
|
end
|
|
|
|
|
|
|
|
if type(value) == 'table' then
|
|
|
|
mTable = getmetatable(value)
|
|
|
|
if mTable == nil then
|
|
|
|
print(spaces ..linePrefix.."(table) ")
|
|
|
|
else
|
|
|
|
print(spaces .."(metatable) ")
|
|
|
|
value = mTable
|
|
|
|
end
|
|
|
|
for tableKey, tableValue in pairs(value) do
|
|
|
|
vardump(tableValue, depth, tableKey)
|
|
|
|
end
|
|
|
|
elseif type(value) == 'function' or
|
|
|
|
type(value) == 'thread' or
|
|
|
|
type(value) == 'userdata' or
|
|
|
|
value == nil
|
|
|
|
then
|
|
|
|
print(spaces..tostring(value))
|
|
|
|
else
|
|
|
|
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print ("HI, this is lua script")
|
|
|
|
|
2014-08-26 12:30:30 -04:00
|
|
|
function ok_cb(extra, success, result)
|
|
|
|
end
|
2014-01-11 19:43:56 -05:00
|
|
|
|
|
|
|
function on_msg_receive (msg)
|
|
|
|
if started == 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if msg.out then
|
|
|
|
return
|
|
|
|
end
|
2014-08-26 12:30:30 -04:00
|
|
|
|
2014-01-11 19:43:56 -05:00
|
|
|
if (msg.text == 'ping') then
|
|
|
|
if (msg.to.id == our_id) then
|
2014-09-08 15:17:47 -04:00
|
|
|
send_msg (msg.from.print_name, 'pong', ok_cb, false)
|
2014-01-11 19:43:56 -05:00
|
|
|
else
|
2014-09-08 15:17:47 -04:00
|
|
|
send_msg (msg.to.print_name, 'pong', ok_cb, false)
|
2014-01-11 19:43:56 -05:00
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if (msg.text == 'PING') then
|
|
|
|
if (msg.to.id == our_id) then
|
|
|
|
fwd_msg (msg.from.print_name, msg.id)
|
|
|
|
else
|
|
|
|
fwd_msg (msg.to.print_name, msg.id)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_our_id (id)
|
|
|
|
our_id = id
|
|
|
|
end
|
|
|
|
|
2014-08-26 12:30:30 -04:00
|
|
|
function on_user_update (user, what)
|
|
|
|
--vardump (user)
|
2014-01-11 19:43:56 -05:00
|
|
|
end
|
|
|
|
|
2014-08-26 12:30:30 -04:00
|
|
|
function on_chat_update (chat, what)
|
|
|
|
--vardump (chat)
|
2014-01-11 19:43:56 -05:00
|
|
|
end
|
|
|
|
|
2014-08-26 12:30:30 -04:00
|
|
|
function on_secret_chat_update (schat, what)
|
|
|
|
--vardump (schat)
|
2014-01-11 19:43:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function on_get_difference_end ()
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_binlog_replay_end ()
|
|
|
|
started = 1
|
|
|
|
end
|