tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

I have no idea how to create a private chat #2385

Closed cyberbarker closed 1 year ago

cyberbarker commented 1 year ago

Hello! I have two accounts. On the first, I authorize it in my app, and the second on my Mac in the official app. These accounts do not have any messages or chats in common. On the second account, I use a bot to find the user id and use this user id in my app for the first account to create private conversations. I have tried

getUser(userId: userId) (code: 400, message: "User not found")
createPrivateChat(force: false, userId: userId) (code: 400, message: "Chat info not found")

I looked at closed issues but did not find a solution that would help me. I am authorized in the application and use part of the functionality without problems.

I don't have a user lock/block/stop list. What must I do to create a private chat between my accounts?

AYMENJD commented 1 year ago

Where did you get the user_id from?

cyberbarker commented 1 year ago

Where did you get the user_id from?

On the second account via @userinfobot and hardcode it in the app

AYMENJD commented 1 year ago

You must never hardcode the user_id, the second account must meet the first account anywhere in Telegram. So you can get it's user_id by an update from TDLib.

You can try using searchPublicChat, with the username of the first account and then repeat the process of sending message.