Skip to content

Commit

Permalink
more test operations
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-zhur committed Sep 7, 2024
1 parent 910065f commit bcea6cf
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public Service2(ExtendedGooglePhotosService extendedGooglePhotosService, ILogger
_videosDatabaseOperations = videosDatabaseOperations;
}

public async Task<List<string>> ListAlbums()
{
await _extendedGooglePhotosService.LoginAsync();
var albums = await _extendedGooglePhotosService.GetAlbumsAsync();
return albums.Select(x => x.title).ToList();
}

public async Task SaveInventory()
{
await _extendedGooglePhotosService.LoginAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using OneShelf.Telegram.Model.CommandAttributes;
using OneShelf.Telegram.Model.Ios;
using OneShelf.Telegram.Services.Base;
using OneShelf.Videos.Database;

namespace OneShelf.Videos.Telegram.Processor.Commands;

[AdminCommand("get_file_size", "Файлик", "Посмотреть файл")]
public class GetFileSize : Command
{
private readonly VideosDatabase _videosDatabase;

public GetFileSize(Io io, VideosDatabase videosDatabase)
: base(io)
{
_videosDatabase = videosDatabase;
}

protected override async Task ExecuteQuickly()
{
var path = Io.FreeChoice("Path to file:");
Io.WriteLine(new FileInfo(path).Length.ToString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using OneShelf.Telegram.Model.CommandAttributes;
using OneShelf.Telegram.Model.Ios;
using OneShelf.Telegram.Services.Base;
using OneShelf.Videos.BusinessLogic.Services;

namespace OneShelf.Videos.Telegram.Processor.Commands;

[AdminCommand("get_file_size", "Файлик", "Посмотреть файл")]
public class ListAlbums : Command
{
private readonly Service2 _service2;

public ListAlbums(Io io, Service2 service2)
: base(io)
{
_service2 = service2;
}

protected override async Task ExecuteQuickly()
{
Scheduled(List());
}

private async Task List()
{
var albums = await _service2.ListAlbums();
foreach (var album in albums)
{
Io.WriteLine(album);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public static IServiceCollection AddProcessor(this IServiceCollection services,

.AddCommand<UpdateCommands>()
.AddCommand<ViewChats>()
.AddCommand<GetFileSize>()
.AddCommand<ListAlbums>()

.AddPipelineHandlerInOrder<UpdatesCollector>()
.AddPipelineHandlerInOrder<DialogHandler>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public List<List<Type>> GetCommandsGrid() => [
typeof(Start),
typeof(Help),
typeof(ViewChats),
typeof(GetFileSize),
typeof(ListAlbums),
],
[
typeof(UpdateCommands),
Expand Down

0 comments on commit bcea6cf

Please sign in to comment.