From e45ee24c49e0cebdbfae2183d38cd629e638abfb Mon Sep 17 00:00:00 2001 From: Dmitrij Vladimirov <47441164+Frisle@users.noreply.github.com> Date: Sat, 30 Aug 2025 13:21:42 +0500 Subject: [PATCH] REFACTOR: lots of syntax changes --- Gitter.Archiver.cls | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Gitter.Archiver.cls b/Gitter.Archiver.cls index 1133c06..56173bb 100644 --- a/Gitter.Archiver.cls +++ b/Gitter.Archiver.cls @@ -7,12 +7,13 @@ Parameter SSLConfig = "DefaultSSL"; /// Downloads all Gitter's room messages to the archive file. Specify fileName and roomID parameters, /// or there would be used default values, which download messages from https://gitter.im/springjazzy/GIS_JKH_Integration -ClassMethod Archive(fileName As %String = "C:\chat.txt", roomID As %String = "56ea6f5f85d51f252ab942cd") As %Status +/// Namespace = set yours namespace +ClassMethod Archive(fileName As %String = "C:\chat.txt", roomID As %String = "56ea6f5f85d51f252ab942cd", Namespace) As %Status { new $namespace zn "%SYS" do:'##class(Security.SSLConfigs).Exists(..#SSLConfig) ##class(Security.SSLConfigs).Create(..#SSLConfig) - + zn Namespace set LIMIT = 100 // default limit for messages load. Could not be higher. set file = ##class(%File).%New(fileName) do file.Open("WSN") @@ -20,7 +21,7 @@ ClassMethod Archive(fileName As %String = "C:\chat.txt", roomID As %String = "56 set req.Server = "api.gitter.im" set req.Https = 1 set req.SSLConfiguration = ..#SSLConfig - set chat = ##class(%Object).$new() + set chat = ##class(%Library.DynamicObject).%New() set beforeId = "" set mes = 0 do { @@ -31,19 +32,19 @@ ClassMethod Archive(fileName As %String = "C:\chat.txt", roomID As %String = "56 req.Get("/v1/rooms/"_roomID_"/chatMessages?limit="_LIMIT _$case(beforeId '= "", 1:"&beforeId="_beforeId, :"")) ) - set obj = ##class(%AbstractObject).$fromJSON(req.HttpResponse.Data) - if (obj.$size() = 0) { continue } - for k=obj.$size()-1:-1:0 { - set message = obj.$get(k) + set obj = ##class(%Library.DynamicAbstractObject).%FromJSON(req.HttpResponse.Data) + if (obj.%size() = 0) { continue } + for k=obj.%size()-1:-1:0 { + set message = obj.%get(k) set mes = mes + 1 - do chat.$set(mes, message) + do chat.%set(mes, message) } write $c(13), "Messages downloaded: ", mes - set beforeId = obj.$get(0).id - } while (obj.$get(LIMIT-1) '= "") // until the last page is reached + set beforeId = obj.%get(0).id + } while (obj.%get(LIMIT-1) '= "") // until the last page is reached write ". Writing to "_fileName_"... " for k=mes:-1:1 { - set message = chat.$get(k) + set message = chat.%get(k) do file.WriteLine( "["_ message.fromUser.displayName_" @ "_message.fromUser.username _"] ["_$piece($replace(message.sent, "T", " "), ".", 1)_"]:"