Update README.md

This commit is contained in:
Afshin Arani 2016-10-01 15:38:21 +03:30 committed by GitHub
parent 6af7c66a81
commit 58143ad978

227
README.md
View file

@ -74,18 +74,6 @@ Currently supported methods:
- [IsPhoneRegistered - Check if phone is registered in Telegram](#isphoneregistered)
- [Authenticate user](#authenticate-user)
- [SignUp user](#signup-user)
- [Get Contact by Phone number](#get-contact-by-phone-number)
- [Get Contact by Username](#get-contact-by-username)
- [Send Message to Contact](#send-message-to-contact)
- [Send Media to Contact](#send-media-to-contact)
- [Get Messages History for Contact](#get-messages-history-for-contact)
- [Get UserFull](#get-userfull)
- [Create Chat](#create-chat)
- [Add Chat user](#add-chat-user)
- [Delete Chat user](#delete-chat-user)
- [Leave Chat](#leave-chat)
- [Get Updates State](#get-updates-state)
- [Get Updates Difference](#get-updates-difference)
####IsPhoneRegistered
Check if phone number registered to Telegram.
@ -135,228 +123,13 @@ _Example_:
**Returns:** **User**, authenticated User.
####Get Contact By Phone number
Get user id by phone number.
_Example_:
```
var res = await client.ImportContactByPhoneNumber("791812312323");
```
* phoneNumber - **string**, phone number in international format (eg. 791812312323)
**Returns**: **int?**, User Id or null if no such user.
####Get Contact By Username
Get user id by userName.
_Example_:
```
var res = await client.ImportByUserName(userName);
```
* userName - **string**, user name (eg. telegram_bot)
**Returns**: **int?**, User Id or null if no such user.
####Send Message To Contact
Send text message to specified user
_Example_:
```
await client.SendMessage(userId, message);
```
* userId - **int**, user id
* message - **string**, message
####Send Media To Contact
Send media file to specified contact.
_Example_:
```
var mediaFile = await client.UploadFile(file_name, file);
var res = await client.SendMediaMessage(userId, mediaFile);
```
* file_name - **string**, file name with extension (eg. "file.jpg")
* file - **byte[]**, file content
* userId - **int**, user id
* mediaFile - **InputFile**, reference to uploaded file
**Returns**: **bool**, file sent or not
####Get Messages History for Contact
Returns messages history for specified userId.
_Example_:
```
var hist = await client.GetMessagesHistoryForContact(userId, offset, limit);
```
* userId - **int**, user id
* offset - **int**, from what index start load history
* limit - **int**, how much items return
**Returns**: **List\<Message\>**, message history
####Get UserFull
Returns user's full information for specified userId.
_Example_:
```
var userFull = await client.GetUserFull(userId);
```
* userId - **int**, user id
**Returns**: **UserFull**, User's information
####Create Chat
Creates a new chat.
_Example_:
```
var statedMessage = await client.CreateChat(title, new List<string> { userId1, userId2 });
```
* title - **string**, chat name
* userIdsToInvite - **List<int>**, list of userIds to invite to chat. Current user will be automatically added to this chat.
**Returns**: **Messages_statedMessageConstructor**, Message that contains information about created chat.
####Add Chat user
Adds a user to a chat and sends a service message on it.
_Example_:
```
var statedMessage = await client.AddChatUser(chatId, userId);
```
* chatId - **int**, Chat ID
* userId - **int**, User ID to be added
**Returns**: **Messages_statedMessageConstructor**, Message that contains information about modified chat.
####Delete Chat user
Deletes a user from a chat and sends a service message on it.
_Example_:
```
var statedMessage = await client.DeleteChatUser(chatId, userId);
```
* chatId - **int**, Chat ID
* userId - **int**, User ID to be deleted
**Returns**: **Messages_statedMessageConstructor**, Message that contains information about modified chat.
####Leave Chat
Leaves the chat by deleting currently authenticated user from it.
_Example_:
```
var statedMessage = await client.LeaveChat(chatId);
```
* chatId - **int**, Chat ID
**Returns**: **Messages_statedMessageConstructor**, Message that contains information about modified chat.
####Get Updates State
Returns a current state of updates.
_Example_:
```
var userFull = await client.GetUpdatesState();
```
**Returns**: **UpdatesState**, Object contains info on state for further updates.
####Get Updates Difference
Returns diffetence between the current state of updates and transmitted.
_Example_:
```
var userFull = await client.GetUpdatesDifference(currentState.pts, currentState.date, currentState.qts);
```
* lastPts - **int**, The most relevant value of parameter pts of (updates.state)
* lastDate - **int**, The most relevant value of parameter date of (updates.state)
* lastQts - **int**, The most relevant value of parameter qts of (updates.state)
**Returns**: **UpdatesDifference**, Occurred changes.
## Contributing
Contributing is highly appreciated!
###How to add new functions
Adding new functions is easy.
* Just create a new Request class in Requests folder.
* Derive it from MTProtoRequest.
Requests specification you can find in [Telegram API](https://core.telegram.org/#api-methods) reference.
_Example_:
```
public class ExampleRequest : MTProtoRequest
{
private int _someParameter;
// pass needed parameters through constructor, and save it to private vars
public InitConnectionRequest(int someParameter)
{
_someParameter = someParameter;
}
// send all needed params to Telegram
public override void OnSend(BinaryWriter writer)
{
writer.Write(_someParameter);
}
// read a received data from Telegram
public override void OnResponse(BinaryReader reader)
{
_someParameter = reader.ReadUInt32();
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Responded { get; }
public override bool Confirmed => true;
}
```
More advanced examples you can find in [Requests folder](https://github.com/sochix/TLSharp/tree/master/TLSharp.Core/Requests).
###What things can I Implement (Project Roadmap)?
* Factor out current TL language implementation, and use [this one](https://github.com/everbytes/SharpTL)
* Add possibility to get current user Chats and Users
* Fix Chat requests (Create, AddUser)
* Add Updates handling
* Add possibility to work with Channels
# FAQ