-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99d76fa
commit a0a99fd
Showing
13 changed files
with
78 additions
and
153 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/TDPDNE.Telegram.Bot/Extensions/BotConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace TDPDNE.Telegram.Bot.Extensions; | ||
|
||
using TDPDNE.Telegram.Bot.Configs; | ||
|
||
public static class BotConfigurationExtensions | ||
{ | ||
public static void OverrideFromEnvs(this BotConfiguration botConfiguration) | ||
{ | ||
botConfiguration.BotToken = Environment.GetEnvironmentVariable("BotConfiguration__BotToken") ?? botConfiguration.BotToken; | ||
botConfiguration.Support = Environment.GetEnvironmentVariable("BotConfiguration__Support") ?? botConfiguration.Support; | ||
botConfiguration.Donations = Environment.GetEnvironmentVariable("BotConfiguration__Donations") ?? botConfiguration.Donations; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/TDPDNE.Telegram.Bot/Extensions.cs → ...t/Extensions/ServiceProviderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace TDPDNE.Telegram.Bot.Infrastructure; | ||
|
||
public record Dickpic | ||
{ | ||
public Guid Id { get; init; } | ||
|
||
public byte[] Picture { get; init; } = default!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace TDPDNE.Telegram.Bot.Infrastructure; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
|
||
public class TDPDNEDbContext : DbContext | ||
{ | ||
public DbSet<Dickpic> Dickpics { get; set; } | ||
|
||
public TDPDNEDbContext(DbContextOptions<TDPDNEDbContext> options) : base(options) | ||
{ | ||
Database.EnsureCreated(); | ||
} | ||
|
||
public async Task<Stream> GetRandomDickpicAsStream() | ||
{ | ||
var dickpic = await Dickpics | ||
.OrderBy(_ => Guid.NewGuid()) | ||
.FirstAsync(); | ||
|
||
return new MemoryStream(dickpic.Picture); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters