革兰氏JS。消息问题。sendMedia,channels.editphoto
我正在创建电报客户端来创建模板频道。我主要获得了我想要的所有功能,但是我被所有暗示上传媒体的功能所困扰:
- message.sendmedia( https://gram.js.org/tl/messages/sendmedia )
- channel.editphoto( https://gram.js.org/tl/channels/editphoto )
当我使用Message.SendMedia方法时,我总是会遇到此错误:
Error: Disconnect (caused from messages.SendMedia)
at /Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/extensions/MessagePacker.js:107:33
at Array.forEach (<anonymous>)
at MessagePacker.rejectAll (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/extensions/MessagePacker.js:105:29)
at MTProtoSender._disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/network/MTProtoSender.js:249:25)
at MTProtoSender.disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/network/MTProtoSender.js:168:20)
at TelegramClient.disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/client/telegramBaseClient.js:163:32)
at _updateLoop (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/client/updates.js:177:26)
这是我执行的代码:
const sendMedia = async (channelId) => {
const file = await client.uploadFile({
file: new CustomFile(
'stakazo.jpeg',
fs.statSync(
'/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/images/xxxxx.jpeg'
).size,
'/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/images/xxxxxx.jpeg'
),
workers: 1,
});
const result = await client.invoke(
new Api.messages.SendMedia({
peer: channelId,
media: new Api.InputMediaUploadedPhoto({
file: file,
ttlSeconds: 43,
}),
message: 'Hello there!',
randomId: BigInt('-4156887774564'),
scheduleDate: 43,
})
);
};
i真的被困在这里。我以为我可能是图像的问题,但没有发现任何东西。
I am creating a telegram client to create templates channels. I got mainly all the functionality I wanted but I got stuck with all the functionality that implies upload media:
- message.sendMedia (https://gram.js.org/tl/messages/SendMedia)
- channel.editPhoto (https://gram.js.org/tl/channels/EditPhoto)
When I use the message.sendMedia method I always get this error:
Error: Disconnect (caused from messages.SendMedia)
at /Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/extensions/MessagePacker.js:107:33
at Array.forEach (<anonymous>)
at MessagePacker.rejectAll (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/extensions/MessagePacker.js:105:29)
at MTProtoSender._disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/network/MTProtoSender.js:249:25)
at MTProtoSender.disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/network/MTProtoSender.js:168:20)
at TelegramClient.disconnect (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/client/telegramBaseClient.js:163:32)
at _updateLoop (/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/node_modules/telegram/client/updates.js:177:26)
And this one is the code I am executing:
const sendMedia = async (channelId) => {
const file = await client.uploadFile({
file: new CustomFile(
'stakazo.jpeg',
fs.statSync(
'/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/images/xxxxx.jpeg'
).size,
'/Users/apple/Desktop/Projects/Telegram-Bots/gram-js/images/xxxxxx.jpeg'
),
workers: 1,
});
const result = await client.invoke(
new Api.messages.SendMedia({
peer: channelId,
media: new Api.InputMediaUploadedPhoto({
file: file,
ttlSeconds: 43,
}),
message: 'Hello there!',
randomId: BigInt('-4156887774564'),
scheduleDate: 43,
})
);
};
I am really stuck here. I thought I might be a problem with the image but did not get to find out anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以使用此代码发送文件(图像,文档等)。
有关更多信息,请参阅本文 - &GT; < sendfile
We can use this code to send the file(image, doc etc.).
For more information refer to this article -> https://gram.js.org/beta/classes/TelegramClient.html#sendFile