我通过 TLSharp 连接到 Telegram 并成功授权,但我不知道如何重新使用我启动的 session 。
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.
关于c# - 如何在 TLSharp 重用 session.dat?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55936037/