Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messages.SendMessage not working as expected #292

Open
Dhruv-Tara opened this issue Oct 16, 2023 · 6 comments
Open

messages.SendMessage not working as expected #292

Dhruv-Tara opened this issue Oct 16, 2023 · 6 comments

Comments

@Dhruv-Tara
Copy link

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
Copy link
Contributor

pogudin-sergey commented Oct 16, 2023

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

peer = {
  _: 'inputPeerChannel',
  channel_id: -1001844107989,
};

@Dhruv-Tara
Copy link
Author

Dhruv-Tara commented Oct 19, 2023

It is a supergroup.

@bonkor
Copy link

bonkor commented Oct 19, 2023

@kaizjen
Copy link

kaizjen commented Mar 23, 2024

@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
Copy link

asror797 commented Apr 18, 2024

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
Copy link

kaizjen commented Apr 23, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@bonkor @pogudin-sergey @asror797 @kaizjen @Dhruv-Tara and others