gotdlib

go-tdlib how to use SearchContacts


I want to search for an unknown user based on the username.

I am using the SearchContacts method from this library. Based on the method signature, the first argument should be a string that represents the query. Unfortunately, I cannot find any documentation on how the query has to be formatted.

Below you can find my code snippet:

contacts, err := telegramClient.SearchContacts(fmt.Sprintf("username=%s", username), 1)

Solution

  • According to the documentation:

    // SearchContacts Searches for the specified query in the first names, last names
    // and usernames of the known user contacts
    // @param query Query to search for; may be empty to return all contacts
    // @param limit The maximum number of users to be returned
    func (client *Client) SearchContacts(query string, limit int32) (*Users, error) {
        // ...
    }
    

    It looks like that function does not search for unknown users, but only for known user contacts.

    It does not look like there is a method to search for unknown users.