我正在使用WTelegramClient库。
下面是我发送消息的方式:
var client = new WTelegram.Client(Config);
await client.LoginUserIfNeeded();
var contacts = await client.Contacts_ImportContacts(new[]
{
new InputPhoneContact { phone = "+998901234567" }
});
if (contacts.imported.Length > 0)
await client.SendMessageAsync(contacts.users[contacts.imported[0].user_id], "Hello, world!");如何发送多个文件?或者至少有一份文件。
我需要从列表或文件夹中发送文件。如果有任何帮助,我将很高兴。
List<byte[]> file = new List<byte[]>();发布于 2022-01-18 12:44:37
来自官方文档的样本
1.获取上传文件夹路径,如下所示。
const string Filepath = @"C:\...\photo.jpg";2.使用客户端和路径上传文件
var inputFile = await client.UploadFileAsync(Filepath);3.将文件发送给对等方(chats.chats[ChatId])
await client.SendMediaAsync(peer, "Here is the photo", inputFile);样本代码
const int ChatId = 1234567890; // the chat we want
const string Filepath = @"C:\...\photo.jpg";
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
await client.LoginUserIfNeeded();
var chats = await client.Messages_GetAllChats(null);
InputPeer peer = chats.chats[ChatId];
var inputFile = await client.UploadFileAsync(Filepath);
await client.SendMediaAsync(peer, "Here is the photo", inputFile);https://stackoverflow.com/questions/70755646
复制相似问题