tdlib / td

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

How i can open one new chat ? #167

Closed zJudGenie closed 6 years ago

zJudGenie commented 6 years ago

if i have the chatid how i can open a new private chat ? I tried to use the metod openchat and the method createprivatechat but nothing. The method open chat return this

 Error {
  code = 3
  message = "Chat not found"
}

and the method createprivatechat return this

Error {
  code = 5
  message = "Chat not found"
}

Thanks for the help

levlam commented 6 years ago

To create a private chat you need a user ID, not a chat ID. When you have some user, you can create a private chat with him through createPrivateChat. Between, createPrivateChat can't return

Error {
  code = 5
  message = "Chat not found"
}
zJudGenie commented 6 years ago

@levlam I took the userId from the chatMember class but it does not work the same, the chatMember class in turn I took it from an array returned from chatMembers I'm using the tdlib version compiled in java Sorry for my english

levlam commented 6 years ago

Then CreatePrivateChat will work for you. The error shown means that you have tried to call some other method.

zJudGenie commented 6 years ago

Thanks, resolved

mortezae commented 5 years ago

Future passers-by may find more details explained by @levlam in this issue

pabx06 commented 5 years ago

i am trying to send a private chat to an user from Channel using tdLib json interface.

getuser(user_id=581197385) works fine and gives me the user .

Then i try to 1)createPrivateChat(chat_id=581197385, force=true) wait 2sec 2) openChat(chat_id=581197385) wait 2 sec 3) sendMessage

i get :

`` {"@type":"error","code":6,"message":"Chat info not found","@extra":"createPrivateChat(581197385,true)"}

{"@type":"error","code":3,"message":"Chat not found","@extra":"openChat(581197385)"}

{"@type":"error","code":5,"message":"Chat not found","@extra":"sendMessage(581197385)"} ``

however sending a message to already started private chat from my smartphone works. my tdLibParams:

  "use_file_database": true,
  "use_chat_info_database": true,
  "use_message_database": true,
  "use_secret_chats": true,
zevlg commented 5 years ago

Then i try to 1)createPrivateChat(chat_id=581197385, force=true)

createPrivateChat user_id:int32 force:Bool = Chat;

there is no "chat_id" in spec

pabx06 commented 5 years ago

true

sotobotero commented 5 years ago

Hello, I have the same problem of above, it is reached when two different clients try to create a chat with the same destination user.

I am susing new TdApi.CreatePrivateChat(userId,false), please I would like to know if TDlib have some mistake.

here is the full log.

I/DLTD: [ 3][t 3][1555260059.309557199][Td.cpp:3302][!Td][&td_requests] Receive request 24: CreatePrivateChat { userId = 876252304 force = false } I/DLTD: [ 3][t 3][1555260945.418469906][Td.cpp:3302][!Td][&td_requests] Receive request 25: CreatePrivateChat { userId = 876252304 force = false } [ 3][t 3][1555260945.418592215][Td.cpp:577][!CreateChatRequest] Receive error for query: [Error : 6 : Chat info not found] [ 3][t 3][1555260945.418617249][Td.cpp:4262][!Td][&td_requests] Sending error for request 25: Error { code = 6 message = "Chat info not found" }

horever, if I try to open chat from telegram aplication whit the same destination user, it works, the problems is only in TDlib. help me please, I have long time working whit this aplication and I do would not like left the project.