zerobias / telegram-mtproto

Telegram client api (MTProto) library
MIT License
620 stars 136 forks source link

#400 CHANNEL_INVALID only using some Phone Numbers #163

Closed mircoianese closed 6 years ago

mircoianese commented 6 years ago

Hi, i'm trying to scrape user info from a supergroup. I've declared the inputChannel object like this in js:


const inputChannel = {
  '_': 'inputChannel',
  'channel_id': 1234567890,
  'access_hash': 'xxxxxxxxxxxxx...'
};

This is the call to getParticipiants method:

const { users, count } = await client('channels.getParticipants', {
      channel: inputChannel,
      filter: { _: 'channelParticipantsRecent' },
      offset: counter * 200,
      limit: 200
    });

Now, the problem is that with some Phone Numbers (after the app gets authorized) i'm getting

[1.788] Error 400 CHANNEL_INVALID 2 1
(node:2850) UnhandledPromiseRejectionWarning: Error: 400 CHANNEL_INVALID CODE#400 CHANNEL_INVALID
    at NetworkerThread.processError (/Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:573:12)
    at /Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:728:34
    at Generator.next (<anonymous>)
    at step (/Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:76:202)
    at /Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:76:459
    at Promise._execute (/Users/mirco/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/Users/mirco/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/Users/mirco/node_modules/bluebird/js/release/promise.js:79:10)
    at /Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:76:99
    at NetworkerThread.processMessage (/Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:770:7)
    at /Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:336:21
    at Generator.next (<anonymous>)
    at step (/Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:76:202)
    at /Users/mirco/node_modules/telegram-mtproto/lib/service/networker/index.js:76:383
    at tryCatcher (/Users/mirco/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/mirco/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/mirco/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/mirco/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/mirco/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/mirco/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/mirco/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Users/mirco/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)

The channel is valid (and it's working with my primary phone number). It's not a country code issue because i tried another Italian Phone Number (i'm from italy) and with other one i'm still getting the same error. Code is the same! I'm using nodejs telegram-mtproto@2.2.8. Also, the phone number that is working is not even member of the Supergroup.

Any ideas? Thanks!

mircoianese commented 6 years ago

Solved by getting Channel ID and Access Hash directly from channel name using contacts.resolveUsername(). I think the Access Hash is different for every user, and thats maybe why it was not working with other accounts than mine.

thanhvuiit commented 6 years ago

@ZombieTheBest can you explain more about that? I got the same error and I don't know how to fix it.

Thanks