public override async Task ProcessAsync(Message message, params string[] arguments) { if (_defaultTransmissionConfiguration == null) { await _botClient.SendTextMessageAsync(message.Chat.Id, "No servers specified. Add servers with /add command"); return; } await _selfUpdatingMessage.Send(message.Chat.Id, async() => { var status = await _transmissionService.GetStatusAsync(_defaultTransmissionConfiguration); if (status == null) { return("Error fetching data"); } return($"Active: {status.ActiveTorrentCount}; Total: {status.torrentCount}; Down speed: {status.downloadSpeed}; Up speed: {status.uploadSpeed}"); }); }
public async Task ProcessAsync(Message message, int count) { if (_defaultTransmissionConfiguration == null) { await _botClient.SendTextMessageAsync(message.Chat.Id, "No servers specified. Add servers with /add command"); return; } await _selfUpdatingMessage.Send(message.Chat.Id, async() => { var torrents = await _transmissionService.GetTorrentsAsync(_defaultTransmissionConfiguration); if (torrents == null) { return("Error fetching data"); } return((torrents.Count() > count ? $"Last {count} added torrents\n" : "All torrents\n") + string.Join("\n", torrents .OrderByDescending(torrent => torrent.AddedDate) .Take(count) .Select(torrent => $"<strong>{torrent.Name}</strong>\n" + $"\t{torrent.Status.GetDisplayName()} ↓{torrent.RateDownload} ↑{torrent.RateUpload} {torrent.PercentDone * 100}%"))); }); }