0

i am trying to write a text to my channel trought telegram api in js. I have a problem, when i perform this call to write myself it works, but when i try to send the text to my channel with

peer: { 
            _: 'inputPeerChannel',
         channel_id: mytelegramchannelid,
         },

it displays this error:

messages.sendMessage error: { _: 'mt_rpc_error', error_code: 400, error_message: 'CHANNEL_INVALID' }

I tried putting -100 before the channel id but it doesn't work, any solution?

Ps: sorry if it is written bad but it's my first post.

Original code:

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

  peer: {
    _: 'inputPeerSelf',
  },
  message: 'Hello @mtproto_core',
  entities: [
    {
      _: 'messageEntityBold',
      offset: 6,
      length: 13,
    },
  ],

  random_id: Math.ceil(Math.random() * 0xffffff) + Math.ceil(Math.random() * 0xffffff),
});

UPDATE: I needed to add channel access_ash to peer:

 peer: { 
     _: 'inputPeerChannel',     
     channel_id: channel_id,
     access_hash: channel_ash,                            
   },

I got access_ash by a contact.resolveUsername api call

 api.call('contacts.resolveUsername', {
      username: channel_username , //without @
    })
deceze
  • 510,633
  • 85
  • 743
  • 889
Frost
  • 1
  • 1

0 Answers0