-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- App uses ASP.NET Core host. - Tool does config management like before and will handle migration to db in the future. - Drop all calls of Console.WriteLine in library in favor of logger.
- Loading branch information
1 parent
fa7c527
commit 4f69375
Showing
42 changed files
with
356 additions
and
332 deletions.
There are no files selected for viewing
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CubicBot.Telegram\CubicBot.Telegram.csproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,9 @@ | ||
using CubicBot.Telegram; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddHostedService<BotService>(); | ||
|
||
var app = builder.Build(); | ||
|
||
await app.RunAsync(); |
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,38 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:11932", | ||
"sslPort": 44318 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5178", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7041;http://localhost:5178", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
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,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"Console": { | ||
"FormatterName": "systemd" | ||
}, | ||
"AllowedHosts": "*" | ||
} |
6 changes: 1 addition & 5 deletions
6
CubicBot.Telegram/CLI/ConfigCommand.cs → CubicBot.Telegram.Tool/CLI/ConfigCommand.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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CubicBot.Telegram\CubicBot.Telegram.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.24209.3" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,158 @@ | ||
using System.CommandLine; | ||
using System.Text; | ||
using CubicBot.Telegram.Tool.CLI; | ||
|
||
var botTokenOption = new CliOption<string?>("--bot-token") | ||
{ | ||
Description = "Telegram bot token.", | ||
}; | ||
var enableCommandsModuleOption = new CliOption<bool?>("--enable-commands-mod") | ||
{ | ||
Description = "Whether to enable the commands module.", | ||
}; | ||
var enableStatsModuleOption = new CliOption<bool?>("--enable-stats-mod") | ||
{ | ||
Description = "Whether to enable the stats module.", | ||
}; | ||
|
||
var enablePersonalCommandsOption = new CliOption<bool?>("--enable-personal-commands") | ||
{ | ||
Description = "Whether to enable personal commands.", | ||
}; | ||
var enableCommonCommandsOption = new CliOption<bool?>("--enable-common-commands") | ||
{ | ||
Description = "Whether to enable common commands.", | ||
}; | ||
var enableDiceCommandsOption = new CliOption<bool?>("--enable-dice-commands") | ||
{ | ||
Description = "Whether to enable dice commands.", | ||
}; | ||
var enableConsentNotNeededCommandsOption = new CliOption<bool?>("--enable-consent-not-needed-commands") | ||
{ | ||
Description = "Whether to enable consent not needed commands.", | ||
}; | ||
var enableNonVeganCommandsOption = new CliOption<bool?>("--enable-non-vegan-commands") | ||
{ | ||
Description = "Whether to enable non-vegan commands.", | ||
}; | ||
var enableLawEnforcementCommandsOption = new CliOption<bool?>("--enable-law-enforcement-commands") | ||
{ | ||
Description = "Whether to enable law enforcement commands.", | ||
}; | ||
var enablePublicServicesCommandsOption = new CliOption<bool?>("--enable-public-services-commands") | ||
{ | ||
Description = "Whether to enable public services commands.", | ||
}; | ||
var enableChineseCommandsOption = new CliOption<bool?>("--enable-chinese-commands") | ||
{ | ||
Description = "Whether to enable Chinese commands.", | ||
}; | ||
var enableChineseTasksCommandsOption = new CliOption<bool?>("--enable-chinese-tasks-commands") | ||
{ | ||
Description = "Whether to enable Chinese tasks commands.", | ||
}; | ||
var enableSystemdCommandsOption = new CliOption<bool?>("--enable-systemd-commands") | ||
{ | ||
Description = "Whether to enable systemd commands.", | ||
}; | ||
|
||
var enableGrassStatsOption = new CliOption<bool?>("--enable-grass-stats") | ||
{ | ||
Description = "Whether to enable grass stats.", | ||
}; | ||
var enableCommandStatsOption = new CliOption<bool?>("--enable-command-stats") | ||
{ | ||
Description = "Whether to enable command stats.", | ||
}; | ||
var enableMessageCounterOption = new CliOption<bool?>("--enable-message-counter") | ||
{ | ||
Description = "Whether to enable message counter.", | ||
}; | ||
var enableTwoTripleThreeOption = new CliOption<bool?>("--enable-two-triple-three") | ||
{ | ||
Description = "Whether to enable two triple three (2333) counter.", | ||
}; | ||
var enableParenthesisEnclosureOption = new CliOption<bool?>("--enable-parenthesis-enclosure") | ||
{ | ||
Description = "Whether to enable parenthesis enclosure.", | ||
}; | ||
|
||
var configGetCommand = new CliCommand("get", "Print config."); | ||
|
||
var configSetCommand = new CliCommand("set", "Change config.") | ||
{ | ||
botTokenOption, | ||
enableCommandsModuleOption, | ||
enableStatsModuleOption, | ||
enablePersonalCommandsOption, | ||
enableCommonCommandsOption, | ||
enableDiceCommandsOption, | ||
enableConsentNotNeededCommandsOption, | ||
enableNonVeganCommandsOption, | ||
enableLawEnforcementCommandsOption, | ||
enablePublicServicesCommandsOption, | ||
enableChineseCommandsOption, | ||
enableChineseTasksCommandsOption, | ||
enableSystemdCommandsOption, | ||
enableGrassStatsOption, | ||
enableCommandStatsOption, | ||
enableMessageCounterOption, | ||
enableParenthesisEnclosureOption, | ||
}; | ||
|
||
configGetCommand.SetAction((_, cancellationToken) => ConfigCommand.GetAsync(cancellationToken)); | ||
configSetCommand.SetAction((parseResult, cancellationToken) => | ||
{ | ||
var botToken = parseResult.GetValue(botTokenOption); | ||
var enableCommandsModule = parseResult.GetValue(enableCommandsModuleOption); | ||
var enableStatsModule = parseResult.GetValue(enableStatsModuleOption); | ||
var enablePersonalCommands = parseResult.GetValue(enablePersonalCommandsOption); | ||
var enableCommonCommands = parseResult.GetValue(enableCommonCommandsOption); | ||
var enableDiceCommands = parseResult.GetValue(enableDiceCommandsOption); | ||
var enableConsentNotNeededCommands = parseResult.GetValue(enableConsentNotNeededCommandsOption); | ||
var enableNonVeganCommands = parseResult.GetValue(enableNonVeganCommandsOption); | ||
var enableLawEnforcementCommands = parseResult.GetValue(enableLawEnforcementCommandsOption); | ||
var enablePublicServicesCommands = parseResult.GetValue(enablePublicServicesCommandsOption); | ||
var enableChineseCommands = parseResult.GetValue(enableChineseCommandsOption); | ||
var enableChineseTasksCommands = parseResult.GetValue(enableChineseTasksCommandsOption); | ||
var enableSystemdCommands = parseResult.GetValue(enableSystemdCommandsOption); | ||
var enableGrassStats = parseResult.GetValue(enableGrassStatsOption); | ||
var enableCommandStats = parseResult.GetValue(enableCommandStatsOption); | ||
var enableMessageCounter = parseResult.GetValue(enableMessageCounterOption); | ||
var enableTwoTripleThree = parseResult.GetValue(enableTwoTripleThreeOption); | ||
var enableParenthesisEnclosure = parseResult.GetValue(enableParenthesisEnclosureOption); | ||
return ConfigCommand.SetAsync( | ||
botToken, | ||
enableCommandsModule, | ||
enableStatsModule, | ||
enablePersonalCommands, | ||
enableCommonCommands, | ||
enableDiceCommands, | ||
enableConsentNotNeededCommands, | ||
enableNonVeganCommands, | ||
enableLawEnforcementCommands, | ||
enablePublicServicesCommands, | ||
enableChineseCommands, | ||
enableChineseTasksCommands, | ||
enableSystemdCommands, | ||
enableGrassStats, | ||
enableCommandStats, | ||
enableMessageCounter, | ||
enableTwoTripleThree, | ||
enableParenthesisEnclosure, | ||
cancellationToken); | ||
}); | ||
|
||
var configCommand = new CliCommand("config", "Print or change config.") | ||
{ | ||
configGetCommand, | ||
configSetCommand, | ||
}; | ||
|
||
var rootCommand = new CliRootCommand("A stupid and annoying chatbot for your group chats.") | ||
{ | ||
configCommand, | ||
}; | ||
|
||
Console.OutputEncoding = Encoding.UTF8; | ||
return await rootCommand.Parse(args).InvokeAsync(); |
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
Oops, something went wrong.