diff --git a/src/main/java/it/tdlight/reactiveapi/transformer/DisableLogs.java b/src/main/java/it/tdlight/reactiveapi/transformer/DisableLogs.java new file mode 100644 index 0000000..f30e5f0 --- /dev/null +++ b/src/main/java/it/tdlight/reactiveapi/transformer/DisableLogs.java @@ -0,0 +1,26 @@ +package it.tdlight.reactiveapi.transformer; + +import it.tdlight.jni.TdApi; +import it.tdlight.jni.TdApi.OptionValueBoolean; +import it.tdlight.reactiveapi.ResultingEvent; +import it.tdlight.reactiveapi.ResultingEvent.TDLibBoundResultingEvent; +import it.tdlight.reactiveapi.ResultingEventTransformer; +import java.util.List; +import reactor.core.publisher.Flux; + +public class DisableLogs implements ResultingEventTransformer { + + @Override + public Flux transform(boolean isBot, Flux events) { + return events.concatMapIterable(event -> { + + // Append SetVerbosityLevel after SetTDLibParameters + if (event instanceof TDLibBoundResultingEvent tdLibBoundResultingEvent + && tdLibBoundResultingEvent.action() instanceof TdApi.SetTdlibParameters) { + return List.of(event, new TDLibBoundResultingEvent<>(new TdApi.SetLogVerbosityLevel(0))); + } + + return List.of(event); + }); + } +}