Giter VIP home page Giter VIP logo

Comments (8)

 avatar commented on July 2, 2024

The CHANNEL_INVALID error is not an Airgram error. It is coming from Telegram. If you are sure you have access to that channels, you should create an issue in tdlib repository.

You need to handle errors to avoid UnhandledPromiseRejectionWarning or crashing server:

try {
  const dialogs = await airgram.client.messages.getHistory({
        // ...
    })
} catch (error) {
  // Something is wrong
  console.error(error.message)
}

Also you can catch all unhandled exceptions to prevent of crashing server:

airgram.catch((error: Error) => {
  if (error.name === 'TDLibError') {
    console.error('TDLib error:', error)
  } else {
    console.log('Other error:', error)
  }
})

from airgram.

ktjd123 avatar ktjd123 commented on July 2, 2024

check if you are using tdlib 1.4.0

from airgram.

zhgromov avatar zhgromov commented on July 2, 2024

This did not help, perhaps because I used the old version of airgram. I tried to run ts-example with the new version and try to get the chat history, but I get errors. Tell me how to get the history of the chat, which is not a member? There is only id in the parameters, access_hash is missing
What I am doing wrong?

 airgram.api.getChatHistory({chatId: 1330724252, limit:10}).then((messages) => {
  console.log(`[Mess] `, JSON.stringify(messages))

})

from airgram.

valoricDe avatar valoricDe commented on July 2, 2024

Hi, I have the same problem, trying to fetch the history via:

airgram.api.getChatHistory({
  chatId: channel_id,
  limit: 10,
  offset: 0,
}).then((response) => {
  assertResponse(response)
  console.log(response)
}).catch(console.error)

And I get Error: RequestError

from airgram.

esindger avatar esindger commented on July 2, 2024

@valoricDe, what is your TDLib version? Can you provide log output please?

from airgram.

valoricDe avatar valoricDe commented on July 2, 2024

I use now 1.5.1 and logLevel 3 and the channel chat id -1001414757191 and the the following

...
[ 3][t 4][1575119222.229680300][Td.cpp:3548][#1][!Td][&td_requests]	Receive request 4: getChatHistory {
  chat_id = -1001414757191
  from_message_id = 0
  offset = 0
  limit = 10
  only_local = false
}
[ 3][t 0][1575119222.229859114][Client.cpp:270][&td_requests]	Begin to wait for updates with timeout 10.000000
[ 3][t 0][1575119222.229868174][Client.cpp:276][&td_requests]	End to wait for updates, returning object 0 0x102315530
...
[ 3][t 4][1575119222.230470896][Td.cpp:3548][#1][!Td][&td_requests]	Receive request 5: getAuthorizationState {
}
[ 3][t 0][1575119222.230587006][Client.cpp:270][&td_requests]	Begin to wait for updates with timeout 10.000000
[ 3][t 0][1575119222.230597258][Client.cpp:276][&td_requests]	End to wait for updates, returning object 0 0x1026131a0
...
[ 3][t 4][1575119222.231589317][RequestActor.h:107][#1][!GetChatHistoryRequest]Receive error for query: [Error : 6 : Chat not found]
[ 3][t 4][1575119222.231620312][Td.cpp:4672][#1][!Td][&td_requests]	Sending result for request 5: authorizationStateReady {
}
[ 3][t 4][1575119222.231651068][Td.cpp:3548][#1][!Td][&td_requests]	Receive request 6: getAuthorizationState {
}
[ 3][t 0][1575119222.231690168][Client.cpp:276][&td_requests]	End to wait for updates, returning object 5 0x102433090
[ 3][t 4][1575119222.231688976][Td.cpp:4687][#1][!Td][&td_requests]	Sending error for request 4: error { code = 6 message = "Chat not found" }
[ 3][t 4][1575119222.231712103][Td.cpp:4672][#1][!Td][&td_requests]	Sending result for request 6: authorizationStateReady {
}
[ 3][t 0][1575119222.231896162][Client.cpp:270][&td_requests]	Begin to wait for updates with timeout 10.000000
[ 3][t 0][1575119222.231907129][Client.cpp:276][&td_requests]	End to wait for updates, returning object 4 0x105000120
{ TDLibError: Chat not found
    at toObject (/Users/velten/Entwicklung/telegram-app/node_modules/@airgram/core/utils.js:39:15)
    at Object.<anonymous> (/Users/velten/Entwicklung/telegram-app/src/airgram/response.ts:5:19)
    at step (/Users/velten/Entwicklung/telegram-app/src/airgram/response.ts:33:23)
    at Object.next (/Users/velten/Entwicklung/telegram-app/src/airgram/response.ts:14:53)
    at fulfilled (/Users/velten/Entwicklung/telegram-app/src/airgram/response.ts:5:58)
    at <anonymous> name: 'TDLibError', code: 6 }
[ 3][t 0][1575119222.239633083][Client.cpp:270][&td_requests]	Begin to wait for updates with timeout 10.000000
[ 3][t 0][1575119222.239653111][Client.cpp:276][&td_requests]	End to wait for updates, returning object 6 0x1050001e0
[ 3][t 0][1575119222.239850998][Client.cpp:270][&td_requests]	Begin to wait for updates with timeout 10.000000
[ 3][t 4][1575119222.287512064][ConfigManager.cpp:509][#1][!Recoverer][&config_recoverer]	ON CONNECTING false
[ 3][t 4][1575119222.287546873][ConfigManager.cpp:689][#1][!Recoverer][&config_recoverer]	Successfully connected
[ 3][t 4][1575119222.287559032][ConfigManager.cpp:753][#1][!Recoverer][&config_recoverer]	Wakeup NEVER
...

from airgram.

valoricDe avatar valoricDe commented on July 2, 2024

You need to call getChats beforehand. But appearently limit 1 is enough, even if the chat is not the first:

airgram.api.getChats({
    limit: 1,
    offsetChatId: 0,
    offsetOrder: '9223372036854775807' // 2^6
  })

Related tdlib/td#791

from airgram.

esindger avatar esindger commented on July 2, 2024

Related to #65

from airgram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.