Closed FragsterAt closed 7 years ago
when we use bots, access_hash is important. this code works:
return client.callApi('contacts.search', {q: '@botname_bot', limit: 10});
}).then(result => {
let userBot = telegramHelper.createObject({user_id: result.users.list[0].id, access_hash: result.users.list[0].access_hash}, 'InputUser');
let peerChat = telegramHelper.createObject({chat_id: chat}, 'InputPeerChat');
return client.callApi('messages.addChatUser', {chat_id: chat, user_id: userBot, fwd_limit:0});
}).then(result => {
var randomID = Math.floor(Math.random() * 0xFFFFFFFF).toString();
return client.callApi('messages.startBot', {bot: userBot, peer: peerChat, random_id:randomID, start_param:'start'});
....
returns error "error_code": 400, "error_message": "BOT_INVALID" I tried peer self, or peer with existing chat - no difference
when i try to add bot to existing chat: return client.callApi('messages.addChatUser', {chat_id: chat, user_id: userBot, fwd_limit:1}); it returns "error_message": "USER_ID_INVALID"
id is bot_id from contacts.search '@chgk_bot' (I also try some other bots, with same result)