alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
625 stars 111 forks source link

messages.SendMessage not working as expected #292

Open Dhruv-Tara opened 9 months ago

Dhruv-Tara commented 9 months ago

I was trying to create a app for my project and when I used the SendMessage method it returned peer id invalid all the id and code was correct

api.call('messages.sendMessage', { clear_draft: true,

peer: { _: 'inputPeerChat', chat_id : -1001844107989 }, message: 'Hello', random_id: 1990, })

image

pogudin-sergey commented 9 months ago

I assume that this is your channel id. Since it has a negative value.

peer = {
  _: 'inputPeerChannel',
  channel_id: -1001844107989,
};
Dhruv-Tara commented 9 months ago

It is a supergroup.

bonkor commented 9 months ago

May be this is the same issue?

https://stackoverflow.com/questions/77236355/different-behavior-telegram-api-for-different-telegram-accounts

https://github.com/alik0211/mtproto-core/issues/286

kaizjen commented 4 months ago

@Dhruv-Tara

It is a supergroup.

Supergroups are also considered channels.

Also, the values for IDs (which in telegram docs are considered long) should be typed as a string, not as a number because of the way this package handles bigints (64-bit numbers)

asror797 commented 3 months ago

Screenshot from 2024-04-18 10-02-59

Anyone can help me.

I have got this error

{
  _: 'mt_rpc_error',
  error_code: 400,
  error_message: 'CHANNEL_INVALID'
}
kaizjen commented 3 months ago

@asror797 check the validity of your access_hash. Each access_hash is unique for both the channel and the current user, which means you have to have it obtained from another Telegram API method, such as dialogs.getDialogs.

Also, I'm not 100% sure about this, but try to remove the -100 from your channel ID, as it is (for some reason) only used for bots. They might've changed it though so I'm not sure about this.