TLSharp
Unofficial Telegram (http://telegram.org) client library implemented in C#. Latest TL scheme supported, thanks to Afshin Arani
๐ฉ Check out TeleJS - a pure JavaScript implementation of Telegram MTP protocol
It's a perfect fit for any developer who would like to send data directly to Telegram users or write own custom Telegram client.
๐ If you โค๏ธ library, please star it! ๐
Table of contents
- How do I add this to my project?
- Dependencies
- Starter Guide
- Available Methods
- Contributors
- FAQ
- Donations
- Support
- License
How do I add this to my project?
Install via NuGet
> Install-Package TLSharp
or build from source
- Clone TLSharp from GitHub
- Compile source with VS2015 or MonoDevelop
- Add reference to
TLSharp.Core.dll
to your awesome project.
Dependencies
TLSharp has a few dependenices, most of functionality implemented from scratch. All dependencies listed in package.conf file.
Starter Guide
To see how to start and how use this library, follow this link. ๐
Available Methods
For your convenience TLSharp have wrappers for several Telegram API methods. You could add your own, see details below.
- IsPhoneRegisteredAsync
- SendCodeRequestAsync
- MakeAuthAsync
- SignUpAsync
- GetContactsAsync
- SendMessageAsync
- SendTypingAsync
- GetUserDialogsAsync
- SendUploadedPhoto
- SendUploadedDocument
- GetFile
- UploadFile
- SendPingAsync
- GetHistoryAsync
What if you can't find needed method at the list?
Don't panic. You can call any method with help of SendRequestAsync
function. For example, send user typing method:
//Create request
var req = new TLRequestSetTyping()
{
Action = new TLSendMessageTypingAction(),
Peer = new TLInputPeerUser() { UserId = user.Id }
};
//run request, and deserialize response to Boolean
return await client.SendRequestAsync<Boolean>(req);
Where you can find a list of requests and its params?
The only way is Telegram API docs. Yes, it's outdated. But there is no other source. Latest scheme in JSON format you can find here
What things can I Implement (Project Roadmap)?
Release 1.0.0
- [DONE]
Add PHONE_MIGRATE handling - [DONE] Add FILE_MIGRATE handling
- Add Updates handling
- [DONE] Add NuGet package
- [DONE] Add wrappers for media uploading and downloading
- Store user session as JSON
FAQ
What API layer is supported?
The latest one - 66. Thanks to Afshin Arani for his TLGenerator
I get a xxxMigrationException or a MIGRATE_X error!
TLSharp library should automatically handle these errors. If you see such errors, please open a new Github issue with the details (include a stacktrace, etc.).
I get an exception: System.IO.EndOfStreamException: Unable to read beyond the end of the stream. All test methos except that AuthenticationWorks and TestConnection return same error. I did every thing including setting api id and hash, and setting server address.-
You should create a Telegram session. See configuration guide
Why do I get a FloodException/FLOOD_WAIT error?
It's likely Telegram restrictions, or a bug in TLSharp (if you feel it's the latter, please open a Github issue). You can know the time to wait by accessing the FloodException::TimeToWait property.
Why does TLSharp lacks feature XXXX?
TLSharp only covers basic functionality of the Telegram protocol, you can be a contributor or a sponsor to speed-up developemnt of any more new features.
Where else to ask for help?
If you think you have found a bug in TLSharp, create a github issue. But if you just have questions about how to use TLSharp, use our gitter channel (https://gitter.im/TLSharp/Lobby) or our Telegram channel (https://t.me/joinchat/AgtDiBEqG1i-qPqttNFLbA).
Attach following information:
- Full problem description and exception message
- Stack-trace
- Your code that runs in to this exception
Without information listen above your issue will be closed.
Donations
Thanks for donations! It's highly appreciated.
List of donators:
Support
If you have troubles while using TLSharp, I can help you for an additional fee.
My pricing is 219$/hour. I accept PayPal. To request a paid support write me at Telegram @sochix, start your message with phrase [PAID SUPPORT].
Contributors
- Afshin Arani - TLGenerator, and a lot of other usefull things
- Knocte
License
Please, provide link to an author when you using library
The MIT License
Copyright (c) 2015 Ilya Pirozhenko http://www.sochix.ru/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.