如何在 TLSharp 中重复使用 session.dat?
How to re-use session.dat at TLSharp?
我通过 TLSharp 连接到 Telegram 并成功授权,但我不知道如何重新使用我启动的会话。
session.dat 我在项目路径中。
var client = new TelegramClient(, "");
await client.ConnectAsync();
var hash = await client.SendCodeRequestAsync("");
var code = Console.ReadLine(); // you can change code in debugger
var user = await client.MakeAuthAsync("", hash, code);
Hello! There are a "sessionUserId" parameter in the constructor of the
client object. You can give a unique value for each of your accounts.
In my case i use a phone number to identificate sessions.
public TelegramClient (int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
For example
int apiId = 123456;
string apiHash = "123456";
string phone_number = "1234567890";
var client = new TelegrowTelegramClient (apiId, apiHash, null, phone_number);
It's create a 1234567890.dat file in app folder. Ofcourse you can
write your own ISessionHandler implementation and store sessions
anywhere you want.
我通过 TLSharp 连接到 Telegram 并成功授权,但我不知道如何重新使用我启动的会话。
session.dat 我在项目路径中。
var client = new TelegramClient(, "");
await client.ConnectAsync();
var hash = await client.SendCodeRequestAsync("");
var code = Console.ReadLine(); // you can change code in debugger
var user = await client.MakeAuthAsync("", hash, code);
Hello! There are a "sessionUserId" parameter in the constructor of the client object. You can give a unique value for each of your accounts. In my case i use a phone number to identificate sessions.
public TelegramClient (int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
For example
int apiId = 123456; string apiHash = "123456"; string phone_number = "1234567890"; var client = new TelegrowTelegramClient (apiId, apiHash, null, phone_number);
It's create a 1234567890.dat file in app folder. Ofcourse you can write your own ISessionHandler implementation and store sessions anywhere you want.