Anonymous user
Retrieve and search chat history: Difference between revisions
→{{header|zkl}}: added code
m (→{{header|Tcl}}: added zkl header) |
(→{{header|zkl}}: added code) |
||
Line 273:
=={{header|zkl}}==
<lang zkl>#<
http://tclers.tk/conferences/tcl/:
2017-04-03.tcl 30610 bytes Apr 03, 2017 21:55:37
2017-04-04.tcl 67996 bytes Apr 04, 2017 21:57:01
...
Contents (eg 2017-01-19.tcl):
m 2017-01-19T23:01:02Z ijchain {*** Johannes13__ leaves}
m 2017-01-19T23:15:37Z ijchain {*** fahadash leaves}
m 2017-01-19T23:27:00Z ijchain {*** Buster leaves}
...
#<<<#
var [const] CURL=Import.lib("zklCurl")(); // libCurl instance
template:="http://tclers.tk/conferences/tcl/%4d-%02d-%02d.tcl";
ymd :=Time.Clock.UTC[0,3]; // (y,m,d)
back :=10; // days in the past
needle :=vm.nthArg(0); // search string
date :=Time.Date.subD(ymd.xplode(), back); // date minus days
do(back){
url :=template.fmt(date.xplode());
haystack:=CURL.get(url); // (request bytes, header length)
haystack=haystack[0].del(0,haystack[1]); // remove HTML header
mentions:=haystack.filter("find",needle); // search lines
if(mentions) println("%s\n------\n%s------\n".fmt(url,mentions.text));
date=Time.Date.addYMD(date, 0,0,1); // add one day to date
}</lang>
While zkl supports TCP natively and talking simple HTTP is easy,
Curl is way easier and fully supports the protocol.
The output shows that dates cross month boundaries correctly.
{{out}}
<pre>
$ zkl bbb suchenwi
http://tclers.tk/conferences/tcl/2017-04-23.tcl
------
m 2017-04-23T06:21:25Z {} {suchenwi has become available}
m 2017-04-23T06:37:30Z suchenwi :D
...
------
http://tclers.tk/conferences/tcl/2017-04-24.tcl
------
...
http://tclers.tk/conferences/tcl/2017-05-02.tcl
------
m 2017-05-01T22:17:15Z {} {suchenwi has left}
m 2017-05-02T16:18:36Z ijchain {* avl42 hopes that one of suchenwi's weekend projects will deal with that ...}
------
</pre>
|