- Set Delegate for get updates
- Filter updates
- Filter by type
- Filter by type & linq
- Get specific value from filtered update with RefToken
- Uses methods with a specific type of return that are generated by PTClient.Generator
- The return type is TdResult
var filterAll = new Filter<Update>(x=>Console.WriteLine(x.GetType()));
var filterByLinq = new Filter<UpdateAuthorizationState>(OnAuthorizationStateWaitTdlibParameters,
x => x.AuthorizationState.GetType() == typeof(AuthorizationStateWaitTdlibParameters));
void OnAuthorizationStateWaitTdlibParameters(UpdateAuthorizationState state)
{
//do something
}
var specialValue = new Filter<UpdateNewMessage, string>(x => Console.WriteLine(x), "Message.Content.Text.Text")
- This filter gives you the text of the message
var specialValue = new Filter<UpdateNewMessage, string>(x => Console.WriteLine(x), x=>x.Message.ChatId == 00000000 , "Message.Content.Text.Text")
- When a message is received from a chat with the ChatId 00000000, the text of the message will be provided to you
tdClient.AddDisposableFilter(new Filter<UpdateFile>(x => Console.WriteLine("Downloaded"), x => x.File.Id == 0000 && x.File.Local.IsDownloadingCompleted));
- When the file with the ID 000 is downloaded, it tells you that the file was downloaded
var filters = new List<IFilter>(//anyfilter):
tdClient = new TdClient(filters);
tdClient.Run();
TdlibParameters parameters = new()
{
//// parameters
};
tdClient.Send(new SetTdlibParameters(parameters));
TdResult<Ok> tdResult = await tdClient.SetAuthenticationPhoneNumberAsync(new SetAuthenticationPhoneNumber
{
PhoneNumber = "+1....."
});
if(tdResult.Successful)
{
Console.WriteLine(tdResult.Result);
}
else
{
Console.WriteLine($"Message : {tdResult.Error.Message} Code : {tdResult.Error.Code}");
}
This was my first project and I tried to write a useful and easy project. If you have an idea or opinion, be sure to let me know Also, this project is based on version 1.7 of Telegram.Td, and if you have a higher version of Telegram.Td, share it with me to update the project. An example project will be available soon
Contact with me : Telegram
News : Telegram Channel