unauthorizedAccept option
[dyskinesia.git] / tools / zhistcvt.lua
blob403118c00bc8cc64a45c3f9284438f0b9f8c5899
1 #!/usr/bin/lua
3 local infn = arg[1] or "psyc___psyced.org_@welcome.txt";
4 local tfn = infn..".0";
6 local fi = assert(io.open(infn, "r"));
7 local fo = assert(io.open(tfn, "w"));
9 local cnt = 0;
10 local isk8qutim = arg[2];
11 repeat
12 local sflg = fi:read();
13 if not sflg then break; end;
14 if isk8qutim then
15 if not fi:read() then break; end;
16 end;
17 local suni = fi:read();
18 if not suni then break; end;
19 local sdate = fi:read();
20 if not sdate then break; end;
21 local stext = fi:read();
22 if not stext then break; end;
23 if sflg == "in" then sflg = "*>";
24 elseif sflg == "out" then sflg = "*<";
25 else sflg = "**";
26 end;
27 fo:write(sflg, " ", sdate, " ", suni, "\n", stext, "\n");
28 cnt = cnt+1;
29 until false;
31 fi:close();
32 fo:close();
34 os.remove(infn);
35 os.rename(tfn, infn);
36 if infn:match("%.txt$") then
37 local ifn = infn:sub(1, -4).."idx";
38 os.remove(ifn);
39 end;
41 print(string.format("%i messages converted", cnt));
42 --[[
44 psyc://ketmar.no-ip.org/~ketmar
45 2009/02/27 16:29:16
46 not dad, only family friend %-)