We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Unable to do anything with a channel
Code example
const path = require('path'); const MTProto = require('@mtproto/core'); const api_id = 202xxxxx3; const api_hash = 'c95fbxxxxxxxxxxxx7d9b0f0'; const bottoken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; const bot_id = '6140xxxx684'; const access_hash = '4443xxxxxxxxx438'; const channelId = '-100178570xxxx'; const messageId = '43759'; const server = { webogram: true }; // 1. Create instance const client = new MTProto({ api_id, api_hash, bottoken, server, storageOptions: { path: path.resolve(__dirname, './data/1.json'), }, }); async function downloadFileFromChannel(mtproto, channelId, messageId) { // Get the message object for the specified message ID try { const result = await client.call('channels.getMessages', { channel: { _: 'inputChannel', channel_id: channelId, access_hash: access_hash }, id: { _: 'inputMessageID', id: 43759, } }); console.log(result) const message = result.messages[0]; if (message.media._ !== 'messageMediaDocument') { throw new Error('The message does not contain a document'); } // Get the file location from the message object const document = message.media.document; const fileLocation = { _: 'inputDocumentFileLocation', id: document.id, access_hash: document.access_hash, file_reference: document.file_reference }; // Download the file const fileBytes = await downloadFile(mtproto, fileLocation); console.log(fileBytes); } catch (e) { console.log(e) } } async function importBotAuthorization(mtproto, botToken) { try { const result = await client.call('auth.importBotAuthorization', { api_id: api_id, api_hash: api_hash, bot_auth_token: botToken }); const { bot } = result; console.log(result); } catch (e) { console.log(e) } } async function getChannelAccessHash(channelId) { try { const inputChannel = { _: 'inputChannel', channel_id: channelId, //access_hash: 0 }; const chatFull = await client.call('channels.getFullChannel', { channel: inputChannel }); const accessHash = chatFull.full_chat.access_hash; console.log('Access hash for the channel:', accessHash); return accessHash; } catch (error) { console.error('Error while getting access hash:', error); } } //importBotAuthorization(mtproto, bottoken); getChannelAccessHash(channelId) //downloadFileFromChannel(mtproto, channelId, messageId);
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Context:
Additional context Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Unable to do anything with a channel
Code example
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Context:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: