Говнокодер

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
local cjson = require "cjson"
counters = {}
local handle = io.popen("cat counters.json")
local json_text = handle:read("*a")
handle:close()
counters = cjson.decode(json_text)
function on_msg_receive(msg)
if(counters[msg.from.phone] == nil) then
counters[msg.from.phone] = 1
else
counters[msg.from.phone] = counters[msg.from.phone] + 1
local f = assert(io.open("counters.json", "w"))
local t = f:write(cjson.encode(counters))
f:close()
end
end