diff --git a/src/Client.cs b/src/Client.cs index af22c38..922925e 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -94,6 +94,9 @@ namespace WTelegram }) { } + public Client(Func configProvider, byte[] startSession, Action saveSession) + : this(configProvider, new ActionStore(startSession, saveSession)) { } + /// Welcome to WTelegramClient! 🙂 /// Config callback, is queried for: api_id, api_hash, session_pathname /// if specified, must support initial Length & Read() of a session, then calls to Write() the updated session. Other calls can be ignored diff --git a/src/Session.cs b/src/Session.cs index b76ecbc..54c354c 100644 --- a/src/Session.cs +++ b/src/Session.cs @@ -192,4 +192,11 @@ namespace WTelegram base.Write(_header, 0, 8); } } + + // QWxp couldn't be bothered to write such a simple SessionStore, so here it is: + internal class ActionStore(byte[] startSession, Action saveSession) : MemoryStream(startSession ?? Array.Empty()) + { + public override void Write(byte[] buffer, int offset, int count) => saveSession(buffer[offset..(offset + count)]); + public override void SetLength(long value) { } + } } \ No newline at end of file