Retrieve and search chat history: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
New post. |
||
Line 277:
}
}
}
=={{header|Java}}==
<syntaxhighlight lang="java">
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public final class RetrieveAndSearchChatHistory {
public static void main(String[] aArgs) throws URISyntaxException, IOException {
String subjectOfSearch = aArgs[0]; // The string 'available' was used to produce the displayed output.
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));
LocalDate tomorrow = now.toLocalDate().plusDays(1);
LocalDate testDate = tomorrow.minusDays(10);
while ( ! testDate.equals(tomorrow ) ) {
URL address = new URI("http://tclers.tk/conferences/tcl/" + testDate + ".tcl").toURL();
HttpURLConnection connection = (HttpURLConnection) address.openConnection();
BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream()) );
System.out.println("Searching chat logs for " + testDate);
String line = "";
while ( ( line = reader.readLine() ).contains(subjectOfSearch) ) {
System.out.println(line);
}
reader.close();
connection.disconnect();
testDate = testDate.plusDays(1);
}
}
}
</syntaxhighlight>
{{ out }}
<pre>
Searching chat logs for 2023-08-28
m 2023-08-27T22:01:36Z {} {kurisu2 has become available}
Searching chat logs for 2023-08-29
Searching chat logs for 2023-08-30
m 2023-08-29T22:04:31Z {} {kevin_walzer has become available}
Searching chat logs for 2023-08-31
Searching chat logs for 2023-09-01
Searching chat logs for 2023-09-02
Searching chat logs for 2023-09-03
Searching chat logs for 2023-09-04
Searching chat logs for 2023-09-05
Searching chat logs for 2023-09-06
</pre>
=={{header|Julia}}==
|