├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Infrabot.Common ├── Contexts │ └── InfrabotContext.cs ├── Domain │ ├── HealthCheckItem.cs │ ├── StatsEvent.cs │ └── StatsItem.cs ├── Enums │ ├── AuditLogEnums.cs │ ├── EventLogType.cs │ └── StatsEventEnums.cs ├── Infrabot.Common.csproj └── Models │ ├── AuditLog.cs │ ├── Configuration.cs │ ├── EventLog.cs │ ├── Group.cs │ ├── GroupPlugin.cs │ ├── HealthCheck.cs │ ├── MessageStat.cs │ ├── PermissionAssignment.cs │ ├── Plugin.cs │ ├── PluginStat.cs │ ├── TelegramMessage.cs │ ├── TelegramUser.cs │ ├── User.cs │ └── UserGroup.cs ├── Infrabot.PluginSystem.Tests ├── HashUtilityTest.cs ├── Infrabot.PluginSystem.Tests.csproj └── PluginUtilityTest.cs ├── Infrabot.TelegramService ├── Commands │ ├── EmergencyCommand.cs │ ├── GetCommandsCommand.cs │ ├── ReloadPluginsCommand.cs │ └── ShowMyIdCommand.cs ├── Core │ ├── IBotCommandsUpdater.cs │ ├── ICommandHandler.cs │ ├── ICommandHandlerFactory.cs │ ├── IEmergencyStateManager.cs │ ├── IPluginRegistry.cs │ └── ITelegramResponder.cs ├── Extensions │ └── StringExtension.cs ├── Infrabot.TelegramService.csproj ├── Managers │ ├── BotCommandsUpdater.cs │ ├── CommandHandlerFactory.cs │ ├── CommandManager.cs │ ├── EmergencyStateManager.cs │ ├── PluginManager.cs │ └── TelegramResponder.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ └── TelegramService.cs ├── appsettings.Development.json ├── appsettings.json ├── icon.ico ├── test1_plugin_new.plug ├── test2_plugin_new.plug ├── test3_plugin_new.plug └── test4_plugin_new.plug ├── Infrabot.WebUI ├── Constants │ ├── ConfigKeys.cs │ ├── RoutePaths.cs │ └── TempDataKeys.cs ├── Controllers │ ├── AccountController.cs │ ├── ApiController.cs │ ├── AuditLogsController.cs │ ├── ConfigurationController.cs │ ├── DocumentationController.cs │ ├── GroupsController.cs │ ├── HomeController.cs │ ├── LogsController.cs │ ├── MessagesController.cs │ ├── PermissionAssignmentController.cs │ ├── PluginsController.cs │ ├── TelegramUsersController.cs │ └── UsersController.cs ├── Extensions │ └── ServiceCollectionExtensions.cs ├── Infrabot.WebUI.csproj ├── Infrabot.WebUI.csproj.user ├── Models │ ├── ChangePasswordViewModel.cs │ ├── ErrorViewModel.cs │ ├── GroupViewModel.cs │ ├── LoginViewModel.cs │ ├── PermissionAssignmentViewModel.cs │ ├── UploadPluginViewModel.cs │ └── UserViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ ├── ApiService.cs │ ├── AuditLogsService.cs │ ├── ConfigurationService.cs │ ├── GroupsService.cs │ ├── PermissionAssignmentService.cs │ ├── PluginsService.cs │ ├── TelegramMessagesService.cs │ ├── TelegramUsersService.cs │ ├── UserGroupsService.cs │ └── UsersService.cs ├── Utils │ ├── PasswordPolicyChecker.cs │ └── PathNormalizer.cs ├── Views │ ├── Account │ │ ├── AccessDenied.cshtml │ │ ├── ChangePassword.cshtml │ │ └── LogIn.cshtml │ ├── AuditLogs │ │ └── Index.cshtml │ ├── Configuration │ │ └── Index.cshtml │ ├── Documentation │ │ ├── AnswersToQuestions.cshtml │ │ ├── Contents.cshtml │ │ ├── Examples.cshtml │ │ ├── GettingStarted.cshtml │ │ └── Introduction.cshtml │ ├── Groups │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Home │ │ ├── Error404.cshtml │ │ └── Index.cshtml │ ├── Logs │ │ └── Index.cshtml │ ├── Messages │ │ └── Index.cshtml │ ├── PermissionAssignment │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Plugins │ │ ├── Delete.cshtml │ │ ├── Index.cshtml │ │ ├── Upload.cshtml │ │ └── View.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ ├── _Layout.cshtml.css │ │ └── _ValidationScriptsPartial.cshtml │ ├── TelegramUsers │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Users │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Edit.cshtml │ │ ├── Index.cshtml │ │ └── View.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json ├── cert.pfx ├── icon.ico └── wwwroot │ ├── css │ ├── error404.css │ ├── login.css │ ├── logs.css │ └── site.css │ ├── favicon.ico │ ├── img │ ├── add-multiple.svg │ ├── add.svg │ ├── clean.svg │ ├── delete.svg │ ├── documentation │ │ ├── contents │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ └── 5.png │ │ ├── examples │ │ │ ├── example1_1.png │ │ │ ├── example1_2.png │ │ │ ├── example1_3.png │ │ │ ├── example1_4.png │ │ │ ├── example1_5.png │ │ │ ├── example1_6.png │ │ │ ├── example2_1.png │ │ │ ├── example2_2.png │ │ │ ├── example2_3.png │ │ │ ├── example2_4.png │ │ │ ├── example2_5.png │ │ │ ├── example2_6.png │ │ │ ├── example3_1.png │ │ │ ├── example3_2.png │ │ │ ├── example3_3.png │ │ │ ├── example3_4.png │ │ │ ├── example3_5.png │ │ │ ├── example3_6.png │ │ │ ├── example3_7.png │ │ │ ├── example4_1.png │ │ │ ├── example4_2.png │ │ │ ├── example4_3.png │ │ │ ├── example4_4.png │ │ │ ├── example4_5.png │ │ │ ├── example5_1.png │ │ │ ├── example5_2.png │ │ │ ├── example5_3.png │ │ │ ├── example5_4.png │ │ │ ├── example5_5.png │ │ │ ├── example5_6.png │ │ │ └── example5_7.png │ │ └── gettingstarted │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ └── 7.png │ ├── edit.svg │ ├── export_white.svg │ ├── icon_configuration.svg │ ├── icon_documentation.svg │ ├── icon_groups.svg │ ├── icon_home.svg │ ├── icon_logs.svg │ ├── icon_messages.svg │ ├── icon_permission_assignments.svg │ ├── icon_plugins.svg │ ├── icon_telegram_users.svg │ ├── icon_users.svg │ ├── infrabot.png │ ├── messages.svg │ ├── migrate.svg │ ├── notifications.svg │ ├── profile.svg │ ├── refresh.svg │ ├── start_task.svg │ ├── test.svg │ ├── view.svg │ └── warning.svg │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-grid.rtl.css │ │ ├── bootstrap-grid.rtl.css.map │ │ ├── bootstrap-grid.rtl.min.css │ │ ├── bootstrap-grid.rtl.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap-reboot.rtl.css │ │ ├── bootstrap-reboot.rtl.css.map │ │ ├── bootstrap-reboot.rtl.min.css │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ ├── bootstrap-utilities.css │ │ ├── bootstrap-utilities.css.map │ │ ├── bootstrap-utilities.min.css │ │ ├── bootstrap-utilities.min.css.map │ │ ├── bootstrap-utilities.rtl.css │ │ ├── bootstrap-utilities.rtl.css.map │ │ ├── bootstrap-utilities.rtl.min.css │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.css.map │ │ ├── bootstrap.rtl.css │ │ ├── bootstrap.rtl.css.map │ │ ├── bootstrap.rtl.min.css │ │ └── bootstrap.rtl.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.esm.js │ │ ├── bootstrap.esm.js.map │ │ ├── bootstrap.esm.min.js │ │ ├── bootstrap.esm.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ ├── bootstrap.min.js.map │ │ └── popper.min.js │ ├── chart │ └── dist │ │ └── js │ │ └── chart.js │ ├── highlight-js │ └── dist │ │ ├── css │ │ ├── default.min.css │ │ └── vs2015.min.css │ │ └── js │ │ ├── csharp.min.js │ │ ├── highlight.min.js │ │ ├── highlightjs-line-numbers.min.js │ │ └── powershell.min.js │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ ├── jquery │ ├── LICENSE.txt │ └── dist │ │ └── jquery-3.7.1.min.js │ └── select2 │ └── dist │ ├── css │ ├── select2-bootstrap-5-theme.min.css │ └── select2.css │ └── js │ └── select2.min.js ├── Infrabot.WorkerService ├── Extensions │ └── ServiceCollectionExtensions.cs ├── HealthChecker.cs ├── HealthDataCleaner.cs ├── Infrabot.WorkerService.csproj ├── MessageCleaner.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Utils │ └── HardwareInfo.cs ├── appsettings.Development.json ├── appsettings.json └── icon.ico ├── LICENSE.txt ├── README.md ├── Setup ├── CodeDependencies.iss ├── InfrabotSetup.iss ├── InfrabotSetupPluginEditor.iss └── files │ ├── Examples │ ├── AzureADSync.plug │ ├── GetServiceStatus.plug │ ├── ManageActiveDirectory.plug │ ├── ManageBitLocker.plug │ └── RestartServer.plug │ ├── PluginEditor │ └── .gitkeep │ ├── TelegramService │ └── .gitkeep │ ├── WebUI │ └── .gitkeep │ ├── WorkerService │ └── .gitkeep │ ├── database │ ├── database.db │ ├── database.db-shm │ └── database.db-wal │ ├── logs │ ├── TelegramService │ │ └── .gitkeep │ ├── WebUI │ │ └── .gitkeep │ └── WorkerService │ │ └── .gitkeep │ ├── nssm-2.24 │ ├── win32 │ │ └── nssm.exe │ └── win64 │ │ └── nssm.exe │ └── plugins │ └── .gitkeep ├── assets ├── 1.PNG ├── 2.PNG ├── 3.PNG ├── 4.PNG ├── 5.PNG ├── 6.PNG ├── 7.PNG ├── demo.gif ├── footer_fixed.svg ├── header.svg └── infrabot.png ├── infrabot.PluginEditor ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Documentation │ └── HelpDocumentation.xml ├── Images │ ├── about.png │ ├── add.png │ ├── close.png │ ├── exit.png │ ├── export.png │ ├── github.png │ ├── help.png │ ├── i.png │ ├── icon.ico │ ├── import.png │ ├── newfile.png │ ├── openfile.png │ ├── remove.png │ └── save.png ├── LICENSE.txt ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Notifiers │ ├── ExecutionFileArgumentWrapper.cs │ ├── PluginExecutionWrapper.cs │ ├── PluginSettingWrapper.cs │ └── PluginWrapper.cs ├── Utils │ └── CommonUtils.cs ├── Windows │ ├── AboutDialog.xaml │ ├── AboutDialog.xaml.cs │ ├── ExecuteCommandsDialog.xaml │ ├── ExecuteCommandsDialog.xaml.cs │ ├── ExecutionFileArgumentsDialog.xaml │ ├── ExecutionFileArgumentsDialog.xaml.cs │ ├── HelpDialog.xaml │ ├── HelpDialog.xaml.cs │ ├── PluginSettingsDialog.xaml │ └── PluginSettingsDialog.xaml.cs ├── icon.ico ├── infrabot.PluginEditor.csproj └── infrabot.PluginEditor.csproj.user ├── infrabot.PluginSystem ├── CreatePluginExample.txt ├── Data │ └── PluginFile.cs ├── Enums │ ├── CommandExecuteTypes.cs │ ├── PluginSettingType.cs │ └── PluginType.cs ├── Execution │ ├── ExecutionFileArgument.cs │ ├── PluginExecution.cs │ └── PluginSetting.cs ├── Plugin.cs ├── Utils │ ├── EncryptionUtility.cs │ ├── HashUtility.cs │ └── PluginUtility.cs └── infrabot.PluginSystem.csproj ├── infrabot.sln └── scheme.txt /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Infrabot Code of Conduct 2 | 3 | ## Purpose 4 | The Infrabot Code of Conduct ensures a respectful, secure, and productive environment for all users and contributors. It applies to anyone interacting with or contributing to the Infrabot ecosystem, including its plugins, services, and communication channels. 5 | 6 | --- 7 | 8 | ## 1. Respect and Professionalism 9 | - Treat all users with respect and courtesy. 10 | - Be patient and constructive in discussions, especially when addressing mistakes. 11 | - Harassment, discrimination, or abusive language will not be tolerated. 12 | 13 | --- 14 | 15 | ## 2. Responsible Usage 16 | - Do not use Infrabot for any malicious, illegal, or unethical activity. 17 | - Ensure that any command or plugin you use or create adheres to company policies and legal requirements. 18 | - Avoid running commands that can cause harm to infrastructure unless explicitly authorized. 19 | 20 | --- 21 | 22 | ## 3. Security and Privacy 23 | - Do not expose sensitive data (e.g., tokens, credentials, personal information) in logs, commands, or shared messages. 24 | - Use encryption and secure practices when handling configuration files, services, and user data. 25 | - Report any security issues immediately to the system administrator or designated security contact. 26 | 27 | --- 28 | 29 | ## 4. Plugin and Feature Contributions 30 | - Keep plugins modular, well-documented, and tested. 31 | - Do not include hard-coded credentials or system paths in plugins. 32 | - Clearly describe what a plugin does before enabling or sharing it with others. 33 | 34 | --- 35 | 36 | ## 5. Logging and Auditing 37 | - All administrative actions may be logged for auditing purposes. 38 | - Users are responsible for actions taken through their access credentials. 39 | - Tampering with logs or bypassing audit mechanisms is strictly prohibited. 40 | 41 | --- 42 | 43 | ## 6. Enforcement 44 | Violations of this Code of Conduct may result in access restrictions, removal of offending content or plugins, or disciplinary action in line with company policy. 45 | 46 | --- 47 | 48 | ## 7. Changes 49 | This Code of Conduct may be updated as Infrabot evolves. Users are expected to review and comply with the latest version. 50 | -------------------------------------------------------------------------------- /Infrabot.Common/Domain/HealthCheckItem.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Domain 2 | { 3 | public class HealthCheckItem 4 | { 5 | public HealthCheckItem() { } 6 | public int RamUsage { get; set; } 7 | public int CpuUsage { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Infrabot.Common/Domain/StatsEvent.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Enums; 2 | 3 | namespace Infrabot.Common.Domain 4 | { 5 | public class StatsEvent 6 | { 7 | public StatsEvent() { } 8 | public DateTime EventDate { get; set; } 9 | public EventLogType EventType { get; set; } 10 | public string Description { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Infrabot.Common/Domain/StatsItem.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Domain 2 | { 3 | public class StatsItem 4 | { 5 | public StatsItem() 6 | { 7 | Plugins = 0; 8 | Users = 0; 9 | TelegramUsers = 0; 10 | TelegramMessages = 0; 11 | StatsEvents = new List { }; 12 | } 13 | public int Plugins { get; set; } 14 | public int Users { get; set; } 15 | public int TelegramUsers { get; set; } 16 | public int TelegramMessages { get; set; } 17 | public List StatsEvents { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Infrabot.Common/Enums/AuditLogEnums.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Enums 2 | { 3 | public enum AuditLogAction 4 | { 5 | None, 6 | Create, 7 | Delete, 8 | Update, 9 | Migrate, 10 | Clean, 11 | LogOut, 12 | LogIn, 13 | ChangePassword, 14 | Access 15 | } 16 | 17 | public enum AuditLogItem 18 | { 19 | Plugin, 20 | User, 21 | TelegramUser, 22 | PermissionAssignment, 23 | Configuration, 24 | Group 25 | } 26 | 27 | public enum AuditLogResult 28 | { 29 | Success, 30 | Failure, 31 | Error, 32 | Denied, 33 | NotFound, 34 | None 35 | } 36 | 37 | public enum AuditLogSeverity 38 | { 39 | Lowest, 40 | Low, 41 | Medium, 42 | Higer, 43 | Highest 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Infrabot.Common/Enums/EventLogType.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Enums 2 | { 3 | public enum EventLogType 4 | { 5 | None = 0, 6 | Error = 1, 7 | Warning = 2, 8 | Info = 3 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Infrabot.Common/Enums/StatsEventEnums.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Enums 2 | { 3 | public enum StatsEventType 4 | { 5 | None = 0, 6 | Error = 1, 7 | Warning = 2, 8 | Info = 3 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Infrabot.Common/Infrabot.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/AuditLog.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Enums; 2 | 3 | namespace Infrabot.Common.Models 4 | { 5 | public class AuditLog 6 | { 7 | public int Id { get; set; } 8 | public string? IPAddress { get; set; } = string.Empty; 9 | public string? Description { get; set; } = string.Empty; 10 | public AuditLogAction LogAction { get; set; } 11 | public AuditLogItem LogItem { get; set; } 12 | public AuditLogResult LogResult { get; set; } 13 | public AuditLogSeverity LogSeverity { get; set; } 14 | public DateTime CreatedDate { get; set; } = DateTime.Now; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/Configuration.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class Configuration 4 | { 5 | public int Id { get; set; } 6 | public string? TelegramBotToken { get; set; } = string.Empty; 7 | public bool TelegramEnableEmergency { get; set; } = true; 8 | public bool TelegramEnableShowMyId { get; set; } = true; 9 | public string? TelegramPowerShellPath { get; set; } = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"; 10 | public string? TelegramPowerShellArguments { get; set; } = "-ExecutionPolicy Unrestricted -NoProfile"; 11 | public string? TelegramLinuxShellPath { get; set; } = "/bin/bash"; 12 | public string? TelegramLinuxShellArguments { get; set; } = ""; 13 | public string? TelegramPythonPath { get; set; } = "/usr/bin/python"; 14 | public string? TelegramPythonArguments { get; set; } = ""; 15 | public int TelegramResultMaxLength { get; set; } = 12000; 16 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/EventLog.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Enums; 2 | 3 | namespace Infrabot.Common.Models 4 | { 5 | public class EventLog 6 | { 7 | public int Id { get; set; } 8 | public string Description { get; set; } = string.Empty; 9 | public EventLogType EventType { get; set; } = EventLogType.None; 10 | public DateTime CreatedDate { get; set; } = DateTime.Now; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/Group.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class Group 4 | { 5 | public int Id { get; set; } 6 | 7 | public string Name { get; set; } = string.Empty; 8 | public DateTime CreatedDate { get; set; } = DateTime.Now; 9 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 10 | 11 | // Navigation property for group-to-user relationships 12 | public List? UserGroups { get; set; } 13 | 14 | // Navigation property for group-to-plugin relationships 15 | public ICollection? GroupPlugins { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/GroupPlugin.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations.Schema; 2 | 3 | namespace Infrabot.Common.Models 4 | { 5 | public class GroupPlugin 6 | { 7 | public int Id { get; set; } 8 | public int GroupId { get; set; } 9 | [ForeignKey("GroupId")] 10 | public Group? Group { get; set; } 11 | 12 | public int PluginId { get; set; } 13 | [ForeignKey("PluginId")] 14 | public Plugin? Plugin { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/HealthCheck.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class HealthCheck 4 | { 5 | public int Id { get; set; } 6 | public string? Data { get; set; } = ""; 7 | public DateTime CreatedDate { get; set; } = DateTime.Now; 8 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/MessageStat.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class MessageStat 4 | { 5 | public int Hour { get; set; } 6 | public int Count { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/PermissionAssignment.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class PermissionAssignment 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } = string.Empty; 7 | 8 | // Many-to-many: one permission assignment can relate to many plugins. 9 | public ICollection Plugins { get; set; } = new List(); 10 | 11 | // Many-to-many: assigned Telegram users. 12 | public ICollection TelegramUsers { get; set; } = new List(); 13 | 14 | // Many-to-many: assigned Groups. 15 | public ICollection Groups { get; set; } = new List(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/Plugin.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class Plugin 4 | { 5 | public int Id { get; set; } 6 | public Guid Guid { get; set; } 7 | public string? Name { get; set; } 8 | public string? PluginType { get; set; } 9 | public DateTime CreatedDate { get; set; } = DateTime.Now; 10 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 11 | 12 | // Navigation property for group-to-plugin relationships 13 | public ICollection? GroupPlugins { get; set; } 14 | 15 | // New unified permission assignments. 16 | public ICollection PermissionAssignments { get; set; } = new List(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/PluginStat.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class PluginStat 4 | { 5 | public string PluginType { get; set; } 6 | public int Count { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/TelegramMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class TelegramMessage 4 | { 5 | public int Id { get; set; } 6 | public string? Message { get; set; } 7 | public long? TelegramUserId { get; set; } 8 | public string? TelegramUserUsername { get; set; } 9 | public DateTime CreatedDate { get; set; } = DateTime.Now; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/TelegramUser.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.Common.Models 2 | { 3 | public class TelegramUser 4 | { 5 | public int Id { get; set; } 6 | public string? Name { get; set; } 7 | public string? Surname { get; set; } 8 | public int TelegramId { get; set; } 9 | public DateTime CreatedDate { get; set; } = DateTime.Now; 10 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 11 | 12 | // Navigation property for user-to-group relationships 13 | public List? UserGroups { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/User.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | 3 | namespace Infrabot.Common.Models 4 | { 5 | public class User : IdentityUser 6 | { 7 | public string Name { get; set; } = string.Empty; 8 | public string Surname { get; set; } = string.Empty; 9 | public bool Enabled { get; set; } = true; 10 | public DateTime LastLoginDate { get; set; } = DateTime.Now; 11 | public DateTime CreatedDate { get; set; } = DateTime.Now; 12 | public DateTime UpdatedDate { get; set; } = DateTime.Now; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Infrabot.Common/Models/UserGroup.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations.Schema; 2 | 3 | namespace Infrabot.Common.Models 4 | { 5 | public class UserGroup 6 | { 7 | public int Id { get; set; } 8 | public int GroupId { get; set; } 9 | [ForeignKey("GroupId")] 10 | public Group? Group { get; set; } 11 | 12 | public int TelegramUserId { get; set; } 13 | [ForeignKey("TelegramUserId")] 14 | public TelegramUser? TelegramUser { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Infrabot.PluginSystem.Tests/HashUtilityTest.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Utils; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Infrabot.PluginSystem.Test 9 | { 10 | public class HashUtilityTest 11 | { 12 | [SetUp] 13 | public void Setup() 14 | { 15 | } 16 | 17 | [Test] 18 | public void CalculateSHA256_ReturnsCorrectHash_WhenFileExists() 19 | { 20 | // Arrange 21 | var tempFile = Path.GetTempFileName(); 22 | try 23 | { 24 | File.WriteAllText(tempFile, "Hello, world!"); 25 | // Known SHA256 hash of "Hello, world!" text 26 | string expectedHash = "315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3".ToUpperInvariant(); 27 | 28 | // Act 29 | var result = HashUtility.CalculateSHA256(tempFile); 30 | 31 | // Assert 32 | Assert.That(result, Is.EqualTo(expectedHash)); 33 | } 34 | finally 35 | { 36 | File.Delete(tempFile); 37 | } 38 | } 39 | 40 | [Test] 41 | public void CalculateSHA256_ReturnsErrorString_WhenFileDoesNotExist() 42 | { 43 | // Arrange 44 | var invalidPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".txt"); 45 | 46 | // Act 47 | var result = HashUtility.CalculateSHA256(invalidPath); 48 | 49 | // Assert 50 | Assert.That(result, Is.EqualTo("file_does_not_exist")); 51 | } 52 | 53 | [Test] 54 | public void CalculateSHA256_ReturnsHexStringWithoutDashes() 55 | { 56 | var tempFile = Path.GetTempFileName(); 57 | try 58 | { 59 | File.WriteAllText(tempFile, "sample"); 60 | 61 | var hash = HashUtility.CalculateSHA256(tempFile); 62 | 63 | // Assert format (length = 64 hex chars, no dashes) 64 | Assert.That(hash, Does.Match("^[A-F0-9]{64}$")); 65 | } 66 | finally 67 | { 68 | File.Delete(tempFile); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Infrabot.PluginSystem.Tests/Infrabot.PluginSystem.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Commands/EmergencyCommand.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.TelegramService.Core; 2 | using Telegram.Bot.Types; 3 | 4 | namespace Infrabot.TelegramService.Commands 5 | { 6 | public class EmergencyCommand : ICommandHandler 7 | { 8 | private readonly ITelegramResponder _telegramResponder; 9 | private readonly IEmergencyStateManager _stateManager; 10 | public string Command => "/emergency"; 11 | 12 | public EmergencyCommand(ITelegramResponder telegramResponder, IEmergencyStateManager stateManager) 13 | { 14 | _telegramResponder = telegramResponder; 15 | _stateManager = stateManager; 16 | } 17 | 18 | public async Task ExecuteAsync(Message message) 19 | { 20 | // If we find specified file then delete it, and prevent application exit. 21 | // In any other case application goes to exit loop and can not stop receiving /emergency command 22 | // Who knows why this stupid ass shit keeps happening 23 | if (_stateManager.IsExitPrevented()) 24 | { 25 | _stateManager.ClearPreventionFlag(); 26 | return; 27 | } 28 | 29 | await _telegramResponder.SendMarkdown(message.Chat, $"*Shutting down program immediately*"); 30 | 31 | _stateManager.SetPreventionFlag(); 32 | Environment.Exit(0); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Commands/GetCommandsCommand.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem; 2 | using Infrabot.PluginSystem.Execution; 3 | using Infrabot.TelegramService.Core; 4 | using System.Text; 5 | using Telegram.Bot.Types; 6 | 7 | namespace Infrabot.TelegramService.Commands 8 | { 9 | public class GetCommandsCommand : ICommandHandler 10 | { 11 | private readonly ITelegramResponder _telegramResponder; 12 | private readonly IPluginRegistry _pluginRegistry; 13 | public string Command => "/getcommands"; 14 | 15 | public GetCommandsCommand(ITelegramResponder telegramResponder, IPluginRegistry pluginRegistry) 16 | { 17 | _telegramResponder = telegramResponder; 18 | _pluginRegistry = pluginRegistry; 19 | } 20 | 21 | public async Task ExecuteAsync(Message message) 22 | { 23 | StringBuilder sb = new StringBuilder(); 24 | sb.AppendLine("📦 _Available Plugin Commands:_"); 25 | 26 | if (_pluginRegistry.Plugins.Count > 0) 27 | { 28 | foreach (Plugin plugin in _pluginRegistry.Plugins) 29 | { 30 | foreach (PluginExecution pluginExecution in plugin.PluginExecutions) 31 | { 32 | sb.AppendLine($"🔹 *{pluginExecution.CommandName}* \\- `{pluginExecution.Help}`"); 33 | } 34 | } 35 | } 36 | else 37 | { 38 | sb.AppendLine("\t `(empty - add plugins)`"); 39 | } 40 | 41 | var output = sb.ToString(); 42 | await _telegramResponder.SendMarkdown(message.Chat, sb.ToString()); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Commands/ReloadPluginsCommand.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.TelegramService.Core; 2 | using Telegram.Bot.Types; 3 | 4 | namespace Infrabot.TelegramService.Commands 5 | { 6 | public class ReloadPluginsCommand : ICommandHandler 7 | { 8 | private readonly ITelegramResponder _telegramResponder; 9 | private readonly IPluginRegistry _pluginRegistry; 10 | public string Command => "/reloadplugins"; 11 | 12 | public ReloadPluginsCommand(ITelegramResponder telegramResponder, IPluginRegistry pluginRegistry) 13 | { 14 | _telegramResponder = telegramResponder; 15 | _pluginRegistry = pluginRegistry; 16 | } 17 | 18 | public async Task ExecuteAsync(Message message) 19 | { 20 | _pluginRegistry.RefreshPlugins(); 21 | await _telegramResponder.SendMarkdown(message.Chat, "✅ Plugins successfully reloaded"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Commands/ShowMyIdCommand.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.TelegramService.Core; 2 | using Telegram.Bot.Types; 3 | 4 | namespace Infrabot.TelegramService.Commands 5 | { 6 | public class ShowMyIdCommand : ICommandHandler 7 | { 8 | private readonly ITelegramResponder _telegramResponder; 9 | public string Command => "/showmyid"; 10 | 11 | public ShowMyIdCommand(ITelegramResponder telegramResponder) { 12 | _telegramResponder = telegramResponder; 13 | } 14 | 15 | public async Task ExecuteAsync(Message message) 16 | { 17 | await _telegramResponder.SendMarkdown(message.Chat, $"Your id is: *{message.From.Id.ToString().Replace("-", "\\-")}* and your username is *{message.From.Username}*\nChat id is: *{message.Chat.Id.ToString().Replace("-", "\\-")}*"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/IBotCommandsUpdater.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.TelegramService.Core 2 | { 3 | public interface IBotCommandsUpdater 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/ICommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Telegram.Bot.Types; 2 | 3 | namespace Infrabot.TelegramService.Core 4 | { 5 | public interface ICommandHandler 6 | { 7 | string Command { get; } 8 | Task ExecuteAsync(Message message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/ICommandHandlerFactory.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Models; 2 | using Telegram.Bot; 3 | 4 | namespace Infrabot.TelegramService.Core 5 | { 6 | public interface ICommandHandlerFactory 7 | { 8 | List GetBuiltInCommands(); 9 | ITelegramBotClient GetBotClient(); 10 | IPluginRegistry GetPluginRegistry(); 11 | Configuration GetConfiguration(); 12 | ITelegramResponder GetTelegramResponder(); 13 | IBotCommandsUpdater GetBotCommandsUpdater(); 14 | IServiceScopeFactory GetServiceScopeFactory(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/IEmergencyStateManager.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.TelegramService.Core 2 | { 3 | public interface IEmergencyStateManager 4 | { 5 | bool IsExitPrevented(); 6 | void SetPreventionFlag(); 7 | void ClearPreventionFlag(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/IPluginRegistry.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem; 2 | 3 | namespace Infrabot.TelegramService.Core 4 | { 5 | public interface IPluginRegistry 6 | { 7 | IReadOnlyList Plugins { get; } 8 | public void RefreshPlugins(); 9 | public string GetPluginDirectory(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Core/ITelegramResponder.cs: -------------------------------------------------------------------------------- 1 | using Telegram.Bot.Types; 2 | 3 | namespace Infrabot.TelegramService.Core 4 | { 5 | public interface ITelegramResponder 6 | { 7 | Task SendPlain(Chat chat, string message, int maxLength = 12000); 8 | Task SendMarkdown(Chat chat, string message, int maxLength = 12000); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Extensions/StringExtension.cs: -------------------------------------------------------------------------------- 1 | namespace CustomExtensions 2 | { 3 | public static class StringExtension 4 | { 5 | public static string EscapeMarkdown(this string value) 6 | { 7 | value = value.Replace("_", "\\_") 8 | .Replace("[", "\\[") 9 | .Replace(".", "\\.") 10 | .Replace("]", "\\]") 11 | .Replace("(", "\\(") 12 | .Replace(")", "\\)") 13 | .Replace("~", "\\~") 14 | .Replace(">", "\\>") 15 | .Replace("#", "\\#") 16 | .Replace("+", "\\+") 17 | .Replace("-", "\\-") 18 | .Replace("=", "\\=") 19 | .Replace("|", "\\|") 20 | .Replace("{", "\\{") 21 | .Replace("}", "\\}") 22 | .Replace("!", "\\!"); 23 | 24 | return value; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Infrabot.TelegramService.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | dotnet-Infrabot.TelegramService-08f9afa2-1df1-4ca7-a6c1-7d276e3355fb 8 | icon.ico 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Managers/EmergencyStateManager.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.TelegramService.Core; 2 | 3 | namespace Infrabot.TelegramService.Managers 4 | { 5 | public class EmergencyStateManager : IEmergencyStateManager 6 | { 7 | private readonly string lockFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "emergency.lock"); 8 | 9 | public bool IsExitPrevented() => File.Exists(lockFile); 10 | 11 | public void SetPreventionFlag() 12 | { 13 | if (!File.Exists(lockFile)) 14 | File.Create(lockFile).Dispose(); 15 | } 16 | 17 | public void ClearPreventionFlag() 18 | { 19 | if (File.Exists(lockFile)) 20 | File.Delete(lockFile); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Managers/TelegramResponder.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.TelegramService.Core; 2 | using Telegram.Bot; 3 | using Telegram.Bot.Exceptions; 4 | using Telegram.Bot.Types; 5 | using Telegram.Bot.Types.Enums; 6 | 7 | namespace Infrabot.TelegramService.Managers 8 | { 9 | public class TelegramResponder : ITelegramResponder 10 | { 11 | private readonly ITelegramBotClient _botClient; 12 | private readonly ILogger _logger; 13 | 14 | public TelegramResponder(ITelegramBotClient botClient, ILogger logger) 15 | { 16 | _botClient = botClient; 17 | _logger = logger; 18 | _logger.LogInformation("Init: Telegram responder"); 19 | } 20 | 21 | public async Task SendPlain(Chat chat, string message, int maxLength = 12000) 22 | { 23 | try 24 | { 25 | await SendSplit(chat, message, ParseMode.None, maxLength); 26 | } 27 | catch (ApiRequestException ex) 28 | { 29 | _logger.LogError("Error while sending message: " + ex.ToString()); 30 | } 31 | catch (Exception ex) 32 | { 33 | _logger.LogError("Error while sending message: " + ex.ToString()); 34 | } 35 | } 36 | 37 | public async Task SendMarkdown(Chat chat, string message, int maxLength = 12000) 38 | { 39 | try 40 | { 41 | await SendSplit(chat, message, ParseMode.MarkdownV2, maxLength); 42 | } 43 | catch (ApiRequestException ex) 44 | { 45 | _logger.LogError("Error while sending message: " + ex.ToString()); 46 | } 47 | catch (Exception ex) 48 | { 49 | _logger.LogError("Error while sending message: " + ex.ToString()); 50 | } 51 | } 52 | 53 | private async Task SendSplit(Chat chat, string text, ParseMode parseMode, int maxLength) 54 | { 55 | for (int i = 0; i < text.Length; i += 4096) 56 | { 57 | string chunk = text.Substring(i, Math.Min(4096, text.Length - i)); 58 | await _botClient.SendTextMessageAsync( 59 | chatId: chat.Id, 60 | text: chunk, 61 | parseMode: parseMode 62 | ); 63 | 64 | if (i > maxLength) 65 | { 66 | _logger.LogWarning("Message exceeded max length ({Max}). Output was truncated.", maxLength); 67 | break; 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Program.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.TelegramService.Core; 3 | using Infrabot.TelegramService.Managers; 4 | using Infrabot.TelegramService.Services; 5 | using Microsoft.EntityFrameworkCore; 6 | using Serilog; 7 | 8 | var builder = Host.CreateApplicationBuilder(args); 9 | 10 | /*****************************************/ 11 | /* Add service definition for Windows */ 12 | builder.Services.AddWindowsService(options => { options.ServiceName = "Infrabot Telegram Bot Service"; }); 13 | 14 | /*****************************************/ 15 | /* Add database connection */ 16 | builder.Services.AddDbContext(options => options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"))); 17 | 18 | /*****************************************/ 19 | /* Enable logs to appear in events */ 20 | var configuration = new ConfigurationBuilder() 21 | .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) 22 | .AddJsonFile("appsettings.json") 23 | .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true) 24 | .Build(); 25 | 26 | builder.Services.AddSerilog(config => 27 | { 28 | config.ReadFrom.Configuration(builder.Configuration); 29 | }); 30 | 31 | /*****************************************/ 32 | /* Enable main Worker service */ 33 | builder.Services.AddSingleton(); 34 | builder.Services.AddSingleton(); 35 | builder.Services.AddSingleton(sp => (PluginManager)sp.GetRequiredService()); 36 | builder.Services.AddHostedService(sp => sp.GetRequiredService()); 37 | builder.Services.AddHostedService(); 38 | 39 | var host = builder.Build(); 40 | host.Run(); 41 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "Infrabot.TelegramService": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "environmentVariables": { 8 | "DOTNET_ENVIRONMENT": "Development" 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Debug", 10 | "Override": { 11 | "Microsoft": "Debug", 12 | "Microsoft.EntityFrameworkCore.Database.Command": "Error" 13 | } 14 | }, 15 | "WriteTo": [ 16 | { 17 | "Name": "Debug" 18 | }, 19 | { 20 | "Name": "Console" 21 | }, 22 | { 23 | "Name": "File", 24 | "Args": { 25 | "path": "D:\\infrabot\\logs\\TelegramService\\application-.log", 26 | "rollingInterval": "Day", 27 | "rollOnFileSizeLimit": true, 28 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 29 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 30 | } 31 | } 32 | ], 33 | "Enrich": [ 34 | "FromLogContext", 35 | "WithMachineName", 36 | "WithThreadId" 37 | ] 38 | }, 39 | "ConnectionStrings": { 40 | "DefaultConnection": "Data Source=D:\\infrabot\\database\\database.db;" 41 | }, 42 | "Plugins": { 43 | "PluginsDirectory": "D:\\infrabot\\plugins" 44 | }, 45 | "Services": { 46 | "PluginManagerRefreshIntervalSeconds": 60 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Information", 10 | "Override": { 11 | "Microsoft": "Error", 12 | "Microsoft.EntityFrameworkCore.Database.Command": "Error" 13 | } 14 | }, 15 | "WriteTo": [ 16 | { 17 | "Name": "Debug" 18 | }, 19 | { 20 | "Name": "Console" 21 | }, 22 | { 23 | "Name": "File", 24 | "Args": { 25 | "path": "..\\logs\\TelegramService\\application-.log", 26 | "rollingInterval": "Day", 27 | "rollOnFileSizeLimit": true, 28 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 29 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 30 | } 31 | } 32 | ], 33 | "Enrich": [ 34 | "FromLogContext", 35 | "WithMachineName", 36 | "WithThreadId" 37 | ] 38 | }, 39 | "ConnectionStrings": { 40 | "DefaultConnection": "Data Source=..\\database\\database.db;" 41 | }, 42 | "Plugins": { 43 | "PluginsDirectory": "..\\plugins" 44 | }, 45 | "Services": { 46 | "PluginManagerRefreshIntervalSeconds": 60 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Infrabot.TelegramService/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.TelegramService/icon.ico -------------------------------------------------------------------------------- /Infrabot.TelegramService/test1_plugin_new.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.TelegramService/test1_plugin_new.plug -------------------------------------------------------------------------------- /Infrabot.TelegramService/test2_plugin_new.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.TelegramService/test2_plugin_new.plug -------------------------------------------------------------------------------- /Infrabot.TelegramService/test3_plugin_new.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.TelegramService/test3_plugin_new.plug -------------------------------------------------------------------------------- /Infrabot.TelegramService/test4_plugin_new.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.TelegramService/test4_plugin_new.plug -------------------------------------------------------------------------------- /Infrabot.WebUI/Constants/ConfigKeys.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.WebUI.Constants 2 | { 3 | public static class ConfigKeys 4 | { 5 | public const string DefaultConnection = "DefaultConnection"; 6 | public const string EnvironmentVariable = "ASPNETCORE_ENVIRONMENT"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Constants/RoutePaths.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.WebUI.Constants 2 | { 3 | public static class RoutePaths 4 | { 5 | public const string Error404 = "/Home/Error404"; 6 | public const string Error = "/Home/Error"; 7 | public const string DefaultRoute = "{controller=Home}/{action=Index}/{id?}"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/ApiController.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Domain; 2 | using Infrabot.WebUI.Services; 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | namespace Infrabot.WebUI.Controllers 7 | { 8 | [Authorize] 9 | [Route("api/")] 10 | [ApiController] 11 | public class ApiController : ControllerBase 12 | { 13 | private readonly ILogger _logger; 14 | private readonly IApiService _apiService; 15 | private readonly IUsersService _userService; 16 | 17 | public ApiController( 18 | ILogger logger, 19 | IApiService apiService, 20 | IUsersService userService) 21 | { 22 | _logger = logger; 23 | _apiService = apiService; 24 | _userService = userService; 25 | } 26 | 27 | [HttpGet("getresourcemetrics")] 28 | public async Task GetResourceMetrics() 29 | { 30 | var metrics = await _apiService.GetResourceMetrics(); 31 | return Ok(metrics); 32 | } 33 | 34 | [HttpGet("getstats")] 35 | public async Task GetStats() 36 | { 37 | StatsItem statsItem = new StatsItem(); 38 | 39 | statsItem.Plugins = await _apiService.GetPluginsCount(); 40 | statsItem.TelegramUsers = await _apiService.GetTelegramUsersCount(); 41 | statsItem.Users = await _userService.GetUsersCount(); 42 | 43 | var events = await _apiService.GetStats(); 44 | foreach (var _event in events) 45 | { 46 | statsItem.StatsEvents.Add( 47 | new StatsEvent 48 | { 49 | Description = _event.Description, 50 | EventDate = _event.CreatedDate, 51 | EventType = _event.EventType 52 | } 53 | ); 54 | } 55 | 56 | return Ok(statsItem); 57 | } 58 | 59 | [HttpGet("getmessagestats")] 60 | public async Task GetMessageStats() 61 | { 62 | // Get message counts 63 | var messageCounts = await _apiService.GetMessageStats(); 64 | 65 | // Ensure all time slots exist (fill missing hours with 0 messages) 66 | var allHours = new List { 0, 4, 8, 12, 16, 20 }; 67 | var messageData = allHours.Select(hour => new 68 | { 69 | Hour = hour, 70 | Count = messageCounts.FirstOrDefault(m => m.Hour == hour)?.Count ?? 0 71 | }); 72 | 73 | return Ok(messageData); 74 | } 75 | 76 | [HttpGet("getpluginstats")] 77 | public async Task GetPluginStats() 78 | { 79 | var pluginCounts = await _apiService.GetPluginStats(); 80 | return Ok(pluginCounts); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/AuditLogsController.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.WebUI.Services; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Infrabot.WebUI.Controllers 6 | { 7 | [Authorize] 8 | public class AuditLogsController : Controller 9 | { 10 | private readonly ILogger _logger; 11 | private readonly IAuditLogsService _auditLogsService; 12 | 13 | public AuditLogsController( 14 | ILogger logger, 15 | IAuditLogsService auditLogsService) 16 | { 17 | _logger = logger; 18 | _auditLogsService = auditLogsService; 19 | } 20 | 21 | public async Task Index() 22 | { 23 | var telegramMessages = await _auditLogsService.GetAuditLogs(0, 200); 24 | return View(telegramMessages); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/ConfigurationController.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Enums; 2 | using Infrabot.Common.Models; 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Newtonsoft.Json; 6 | using Infrabot.WebUI.Constants; 7 | using Infrabot.WebUI.Services; 8 | 9 | namespace Infrabot.WebUI.Controllers 10 | { 11 | [Authorize] 12 | public class ConfigurationController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | private readonly IConfigurationService _configurationService; 16 | private readonly IAuditLogsService _auditLogsService; 17 | 18 | public ConfigurationController( 19 | ILogger logger, 20 | IConfigurationService configurationService, 21 | IAuditLogsService auditLogsService) 22 | { 23 | _logger = logger; 24 | _configurationService = configurationService; 25 | _auditLogsService = auditLogsService; 26 | } 27 | 28 | public async Task Index() 29 | { 30 | var configuration = await _configurationService.GetConfiguration(); 31 | 32 | if (configuration is null) 33 | { 34 | await _auditLogsService.AddAuditLog(new AuditLog { IPAddress = HttpContext.Connection.RemoteIpAddress?.ToString(), LogAction = AuditLogAction.Access, LogItem = AuditLogItem.Configuration, LogResult = AuditLogResult.Error, LogSeverity = AuditLogSeverity.Highest, CreatedDate = DateTime.Now, Description = $"User {this.User.Identity?.Name} accessed Configuration page but got error about system configuration absense" }); 35 | _logger.LogError("System is corrupted. No configuration in the database has been found. Please delete database and restart application."); 36 | return NotFound(); 37 | } 38 | 39 | return View(configuration); 40 | } 41 | 42 | [HttpPost] 43 | [ValidateAntiForgeryToken] 44 | public async Task Index(Configuration configuration) 45 | { 46 | if (ModelState.IsValid) 47 | { 48 | string serializedConfiguration = JsonConvert.SerializeObject(configuration); 49 | await _auditLogsService.AddAuditLog(new AuditLog { IPAddress = HttpContext.Connection.RemoteIpAddress?.ToString(), LogAction = AuditLogAction.Update, LogItem = AuditLogItem.Configuration, LogResult = AuditLogResult.Success, LogSeverity = AuditLogSeverity.Highest, CreatedDate = DateTime.Now, Description = $"User {this.User.Identity?.Name} changed system configuration to: {serializedConfiguration}" }); 50 | await _configurationService.UpdateConfiguration(configuration); 51 | 52 | _logger.LogInformation("Configuration saved: " + serializedConfiguration); 53 | 54 | ViewData[TempDataKeys.ConfigurationSaved] = true; 55 | } 56 | 57 | return View(configuration); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/DocumentationController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authorization; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace Infrabot.WebUI.Controllers 5 | { 6 | [Authorize] 7 | public class DocumentationController : Controller 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public DocumentationController(ILogger logger) 12 | { 13 | _logger = logger; 14 | } 15 | 16 | public IActionResult Introduction() 17 | { 18 | return View(); 19 | } 20 | 21 | public IActionResult Contents() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult GettingStarted() 27 | { 28 | return View(); 29 | } 30 | 31 | public IActionResult Examples() 32 | { 33 | return View(); 34 | } 35 | 36 | public IActionResult AnswersToQuestions() 37 | { 38 | return View(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using infrabot.Models; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System.Diagnostics; 5 | 6 | namespace infrabot.Controllers 7 | { 8 | [Authorize] 9 | public class HomeController : Controller 10 | { 11 | private readonly ILogger _logger; 12 | 13 | public HomeController(ILogger logger) 14 | { 15 | _logger = logger; 16 | } 17 | 18 | public IActionResult Index() 19 | { 20 | return View(); 21 | } 22 | 23 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 24 | public IActionResult Error() 25 | { 26 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/LogsController.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.WebUI.Services; 2 | using Infrabot.WebUI.Utils; 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | namespace Infrabot.WebUI.Controllers 7 | { 8 | [Authorize] 9 | public class LogsController : Controller 10 | { 11 | private readonly ILogger _logger; 12 | private readonly IAuditLogsService _auditLogsService; 13 | private readonly IConfiguration _configuration; 14 | private string logsFilePath; 15 | 16 | public LogsController( 17 | ILogger logger, 18 | IAuditLogsService auditLogsService, 19 | IConfiguration configuration) 20 | { 21 | _logger = logger; 22 | _auditLogsService = auditLogsService; 23 | _configuration = configuration; 24 | 25 | logsFilePath = PathNormalizer.NormalizePath(_configuration["Serilog:WriteTo:2:Args:path"].Replace(".log", DateTime.Now.ToString("yyyyMMdd") + ".log") ?? "logs"); 26 | 27 | _logger.LogInformation(logsFilePath); 28 | } 29 | 30 | public async Task Index() 31 | { 32 | ViewBag.Logs = await ReadLastLines(logsFilePath, 500); 33 | 34 | return View(); 35 | } 36 | 37 | private async Task ReadLastLines(string filePath, int lineCount) 38 | { 39 | if (!System.IO.File.Exists(filePath)) 40 | { 41 | _logger.LogError($"The specified file does not exist {filePath}"); 42 | return string.Empty; 43 | } 44 | 45 | var lines = new LinkedList(); 46 | try 47 | { 48 | using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) 49 | using (var reader = new StreamReader(fileStream)) 50 | { 51 | while (!reader.EndOfStream) 52 | { 53 | var line = await reader.ReadLineAsync(); 54 | if (line != null) 55 | { 56 | lines.AddLast(line); 57 | if (lines.Count > lineCount) 58 | lines.RemoveFirst(); // Keep only the last `lineCount` lines 59 | } 60 | } 61 | } 62 | } 63 | catch (Exception ex) 64 | { 65 | _logger.LogError($"Error reading file: {ex.Message}"); 66 | } 67 | 68 | return string.Join(Environment.NewLine, lines); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Controllers/MessagesController.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.WebUI.Services; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Infrabot.WebUI.Controllers 6 | { 7 | [Authorize] 8 | public class MessagesController : Controller 9 | { 10 | private readonly ILogger _logger; 11 | private readonly ITelegramMessagesService _telegramMessagesService; 12 | 13 | public MessagesController( 14 | ILogger logger, 15 | ITelegramMessagesService telegramMessagesService) 16 | { 17 | _logger = logger; 18 | _telegramMessagesService = telegramMessagesService; 19 | } 20 | 21 | public async Task Index() 22 | { 23 | var telegramMessages = await _telegramMessagesService.GetTelegramMessages(); 24 | return View(telegramMessages); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Infrabot.WebUI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | icon.ico 8 | 9 | 10 | 11 | <_ContentIncludedByDefault Remove="wwwroot\img\documentation\examples\example5_1.png" /> 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | all 25 | runtime; build; native; contentfiles; analyzers; buildtransitive 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | PreserveNewest 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Infrabot.WebUI.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | https 5 | RazorViewEmptyScaffolder 6 | root/Common/MVC/View 7 | MvcControllerEmptyScaffolder 8 | root/Common/MVC/Controller 9 | 10 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/ChangePasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Infrabot.WebUI.Models 4 | { 5 | public class ChangePasswordViewModel 6 | { 7 | 8 | [DataType(DataType.Password)] 9 | public string OldPassword { get; set; } 10 | 11 | [DataType(DataType.Password)] 12 | public string NewPassword { get; set; } 13 | 14 | [DataType(DataType.Password)] 15 | public string NewPasswordRepeat { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace infrabot.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string? RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/GroupViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.Rendering; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace Infrabot.WebUI.Models 6 | { 7 | public class GroupViewModel 8 | { 9 | public int Id { get; set; } 10 | 11 | [BindProperty] 12 | [Required(ErrorMessage = "Please enter Name")] 13 | public string Name { get; set; } 14 | 15 | // Multi-select for telegram users 16 | [BindProperty] 17 | [Required(ErrorMessage = "Please select Telegram Users")] 18 | public List SelectedTelegramUserIds { get; set; } = new List(); 19 | public IEnumerable AvailableTelegramUsers { get; set; } = new List(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Infrabot.WebUI.Models 4 | { 5 | public class LoginViewModel 6 | { 7 | public string UserName { get; set; } 8 | 9 | [DataType(DataType.Password)] 10 | public string Password { get; set; } 11 | 12 | [Display(Name = "Remember Me")] 13 | public bool RememberMe { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/PermissionAssignmentViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.Rendering; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace Infrabot.WebUI.Models 6 | { 7 | public class PermissionAssignmentViewModel 8 | { 9 | public int Id { get; set; } 10 | 11 | [BindProperty] 12 | [Required(ErrorMessage = "Please provide name")] 13 | public string Name { get; set; } 14 | 15 | // Multi-select for plugins. 16 | [BindProperty] 17 | [Required(ErrorMessage = "Please select Plugins")] 18 | public List SelectedPluginIds { get; set; } = new List(); 19 | public IEnumerable AvailablePlugins { get; set; } = new List(); 20 | 21 | // Multi-select for Telegram users. 22 | [BindProperty] 23 | [Required(ErrorMessage = "Please select Telegram Users")] 24 | public List SelectedTelegramUserIds { get; set; } = new List(); 25 | public IEnumerable AvailableTelegramUsers { get; set; } = new List(); 26 | 27 | // Multi-select for Groups. 28 | [BindProperty] 29 | [Required(ErrorMessage = "Please select Groups")] 30 | public List SelectedGroupIds { get; set; } = new List(); 31 | public IEnumerable AvailableGroups { get; set; } = new List(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/UploadPluginViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.WebUI.Models 2 | { 3 | public class UploadPluginViewModel 4 | { 5 | public List? Files { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Models/UserViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Infrabot.WebUI.Models 4 | { 5 | public class UserViewModel 6 | { 7 | public string Name { get; set; } 8 | public string Surname { get; set; } 9 | public string UserName { get; set; } 10 | public string Email { get; set; } 11 | 12 | [DataType(DataType.Password)] 13 | public string? Password { get; set; } 14 | public string? PhoneNumber { get; set; } 15 | public bool Enabled { get; set; } = true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.WebUI.Constants; 3 | using Infrabot.WebUI.Extensions; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | 8 | /*****************************************/ 9 | /* Add services */ 10 | builder.Services.AddControllersWithViews(); 11 | builder.Services.AddDbContext(options => options.UseSqlite(builder.Configuration.GetConnectionString(ConfigKeys.DefaultConnection), b=> b.MigrationsAssembly("Infrabot.WebUI"))); 12 | builder.Services.AddInfrabotAuthentication(); 13 | builder.Services.AddInfrabotLogging(); 14 | builder.Services.AddInfrabotControllerServices(); 15 | 16 | /*****************************************/ 17 | /* Build application */ 18 | var app = builder.Build(); 19 | 20 | /*****************************************/ 21 | /* Configure the HTTP request pipeline */ 22 | if (!app.Environment.IsDevelopment()) 23 | { 24 | app.UseExceptionHandler(RoutePaths.Error); 25 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 26 | app.UseHsts(); 27 | } 28 | 29 | /*****************************************/ 30 | /* Ensure database is created */ 31 | using (var scope = app.Services.CreateScope()) 32 | { 33 | var dbContext = scope.ServiceProvider.GetRequiredService(); 34 | await dbContext.Database.MigrateAsync(); 35 | await dbContext.Database.EnsureCreatedAsync(); 36 | } 37 | 38 | /*****************************************/ 39 | /* Configure error codes */ 40 | app.Use(async (context, next) => 41 | { 42 | await next(); 43 | if (context.Response.StatusCode == 404) 44 | { 45 | context.Request.Path = RoutePaths.Error404; 46 | await next(); 47 | } 48 | }); 49 | 50 | /*****************************************/ 51 | /* Map services */ 52 | app.UseHttpsRedirection(); 53 | app.UseStaticFiles(); 54 | app.UseRouting(); 55 | app.UseAuthentication(); 56 | app.UseAuthorization(); 57 | app.MapControllerRoute( 58 | name: "default", 59 | pattern: RoutePaths.DefaultRoute); 60 | 61 | /*****************************************/ 62 | /* Run web application */ 63 | app.Run(); 64 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:56850", 8 | "sslPort": 44311 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5283", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7035;http://localhost:5283", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/ApiService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Infrabot.WebUI.Services 6 | { 7 | public interface IApiService 8 | { 9 | Task> GetResourceMetrics(int limit = 7); 10 | Task> GetStats(int limit = 15); 11 | Task> GetMessageStats(); 12 | Task> GetPluginStats(); 13 | Task GetPluginsCount(); 14 | Task GetTelegramUsersCount(); 15 | } 16 | 17 | public class ApiService : IApiService 18 | { 19 | private readonly InfrabotContext _context; 20 | 21 | public ApiService(InfrabotContext context) 22 | { 23 | _context = context; 24 | } 25 | 26 | public async Task> GetResourceMetrics(int limit = 7) 27 | { 28 | var metrics = await _context.HealthChecks.OrderByDescending(x => x.CreatedDate).Take(limit).ToListAsync(); 29 | return metrics; 30 | } 31 | 32 | public async Task> GetStats(int limit = 15) 33 | { 34 | var events = await _context.EventLogs.OrderByDescending(x => x.CreatedDate).Take(limit).ToListAsync(); 35 | return events; 36 | } 37 | 38 | public async Task> GetMessageStats() 39 | { 40 | var now = DateTime.Now; 41 | var startOfDay = DateTime.Now.Date; 42 | 43 | var messageCounts = await _context.TelegramMessages 44 | .Where(m => m.CreatedDate >= startOfDay) // Ensure this is in the correct time zone 45 | .GroupBy(m => (m.CreatedDate.Hour / 4) * 4) // Groups messages into 4-hour intervals 46 | .Select(g => new MessageStat 47 | { 48 | Hour = g.Key, 49 | Count = g.Count() 50 | }) 51 | .ToListAsync(); 52 | 53 | return messageCounts; 54 | } 55 | 56 | public async Task> GetPluginStats() 57 | { 58 | var pluginCounts = await _context.Plugins 59 | .GroupBy(p => p.PluginType) 60 | .Select(g => new PluginStat 61 | { 62 | PluginType = g.Key.ToString(), 63 | Count = g.Count() 64 | }) 65 | .ToListAsync(); 66 | 67 | return pluginCounts; 68 | } 69 | 70 | public async Task GetPluginsCount() 71 | { 72 | int pluginCounts = await _context.Plugins.CountAsync(); 73 | return pluginCounts; 74 | } 75 | 76 | public async Task GetTelegramUsersCount() 77 | { 78 | int telegramUsersCount = await _context.TelegramUsers.CountAsync(); 79 | return telegramUsersCount; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/AuditLogsService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Infrabot.WebUI.Services 6 | { 7 | public interface IAuditLogsService 8 | { 9 | Task> GetAuditLogs(int page = 0, int pageSize = 50); 10 | Task> GetAllAuditLogs(); 11 | Task GetAuditLogsCount(); 12 | Task AddAuditLog(AuditLog auditLog); 13 | } 14 | 15 | public class AuditLogsService : IAuditLogsService 16 | { 17 | private readonly InfrabotContext _context; 18 | 19 | public AuditLogsService(InfrabotContext context) 20 | { 21 | _context = context; 22 | } 23 | 24 | public async Task> GetAuditLogs(int page = 0, int pageSize = 50) 25 | { 26 | var auditLogs = await _context.AuditLogs.OrderByDescending(s => s.CreatedDate).Skip(page * pageSize).Take(pageSize).ToListAsync(); 27 | return auditLogs; 28 | } 29 | 30 | public async Task> GetAllAuditLogs() 31 | { 32 | var auditLogs = await _context.AuditLogs.ToListAsync(); 33 | return auditLogs; 34 | } 35 | 36 | public async Task GetAuditLogsCount() 37 | { 38 | int auditLogsCount = await _context.AuditLogs.CountAsync(); 39 | return auditLogsCount; 40 | } 41 | 42 | public async Task AddAuditLog(AuditLog auditLog) 43 | { 44 | await _context.AuditLogs.AddAsync(auditLog); 45 | var result = await _context.SaveChangesAsync(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/ConfigurationService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Infrabot.WebUI.Services 6 | { 7 | public interface IConfigurationService 8 | { 9 | Task GetConfiguration(); 10 | Task UpdateConfiguration(Configuration configuration); 11 | } 12 | 13 | public class ConfigurationService : IConfigurationService 14 | { 15 | private readonly InfrabotContext _context; 16 | 17 | public ConfigurationService(InfrabotContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public async Task GetConfiguration() 23 | { 24 | var configuration = await _context.Configurations.FirstOrDefaultAsync(s => s.Id == 1); 25 | return configuration; 26 | } 27 | 28 | public async Task UpdateConfiguration(Configuration configuration) 29 | { 30 | _context.Configurations.Update(configuration); 31 | await _context.SaveChangesAsync(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/TelegramMessagesService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Infrabot.WebUI.Services 6 | { 7 | public interface ITelegramMessagesService 8 | { 9 | Task> GetTelegramMessages(int page = 0, int pageSize = 50); 10 | Task> GetAllTelegramMessages(); 11 | Task GetTelegramMessagesCount(); 12 | } 13 | 14 | public class TelegramMessagesService : ITelegramMessagesService 15 | { 16 | private readonly InfrabotContext _context; 17 | 18 | public TelegramMessagesService(InfrabotContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public async Task> GetTelegramMessages(int page = 0, int pageSize = 50) 24 | { 25 | var telegramMessages = await _context.TelegramMessages.OrderByDescending(s => s.CreatedDate).Skip(page * pageSize).Take(pageSize).ToListAsync(); 26 | return telegramMessages; 27 | } 28 | 29 | public async Task> GetAllTelegramMessages() 30 | { 31 | var telegramMessages = await _context.TelegramMessages.ToListAsync(); 32 | return telegramMessages; 33 | } 34 | 35 | public async Task GetTelegramMessagesCount() 36 | { 37 | int telegramMessagesCount = await _context.TelegramMessages.CountAsync(); 38 | return telegramMessagesCount; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/UserGroupsService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | 4 | namespace Infrabot.WebUI.Services 5 | { 6 | public interface IUserGroupsService 7 | { 8 | Task AddRangeUserGroups(List userGroups); 9 | } 10 | public class UserGroupsService : IUserGroupsService 11 | { 12 | private readonly InfrabotContext _context; 13 | 14 | public UserGroupsService(InfrabotContext context) 15 | { 16 | _context = context; 17 | } 18 | 19 | public async Task AddRangeUserGroups(List userGroups) 20 | { 21 | await _context.UserGroups.AddRangeAsync(userGroups); 22 | await _context.SaveChangesAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Services/UsersService.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.Common.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Infrabot.WebUI.Services 6 | { 7 | public interface IUsersService 8 | { 9 | Task> GetUsers(int page = 0, int pageSize = 50); 10 | Task> GetAllUsers(); 11 | Task GetUsersCount(); 12 | } 13 | 14 | public class UsersService : IUsersService 15 | { 16 | private readonly InfrabotContext _context; 17 | 18 | public UsersService(InfrabotContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public async Task> GetUsers(int page = 0, int pageSize = 50) 24 | { 25 | var users = await _context.Users.OrderBy(s => s.UserName).Skip(page * pageSize).Take(pageSize).ToListAsync(); 26 | return users; 27 | } 28 | 29 | public async Task> GetAllUsers() 30 | { 31 | var users = await _context.Users.ToListAsync(); 32 | return users; 33 | } 34 | 35 | public async Task GetUsersCount() 36 | { 37 | int usersCount = await _context.Users.CountAsync(); 38 | return usersCount; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Utils/PasswordPolicyChecker.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.WebUI.Utils 2 | { 3 | public static class PasswordPolicyChecker 4 | { 5 | public static bool CheckPasswordForPolicy( 6 | string password, 7 | int minPasswordLength = 6, 8 | bool containSpecialCharacter = false, 9 | bool containNumber = false, 10 | bool containLowerCase = false, 11 | bool containUpperCase = false 12 | ) 13 | { 14 | // Check minimum length 15 | if (password.Length < minPasswordLength) 16 | { 17 | return false; 18 | } 19 | 20 | // Check for special characters if required 21 | if (containSpecialCharacter && !password.Any(ch => !char.IsLetterOrDigit(ch))) 22 | { 23 | return false; 24 | } 25 | 26 | // Check for numbers if required 27 | if (containNumber && !password.Any(char.IsDigit)) 28 | { 29 | return false; 30 | } 31 | 32 | // Check for lowercase letters if required 33 | if (containLowerCase && !password.Any(char.IsLower)) 34 | { 35 | return false; 36 | } 37 | 38 | // Check for uppercase letters if required 39 | if (containUpperCase && !password.Any(char.IsUpper)) 40 | { 41 | return false; 42 | } 43 | 44 | // If all checks passed 45 | return true; 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Utils/PathNormalizer.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.WebUI.Utils 2 | { 3 | public static class PathNormalizer 4 | { 5 | public static string NormalizePath(string path) 6 | { 7 | return Path.IsPathRooted(path) 8 | ? path 9 | : Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, path)); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Account/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | 10 | Access denied 11 | 12 | 13 | 14 | 15 | 16 | 17 | 66 | 67 | 68 |
69 |
---
70 |
Oops! Access denied!
71 | Go Back Home 72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/AuditLogs/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @model List 3 | @{ 4 | ViewData["Title"] = "Audit logs"; 5 | } 6 | 7 |
8 |
9 |

Audit logs

10 |
11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | @foreach (var auditLog in Model) 28 | { 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | } 40 | 41 |
IdIPDescriptionActionItemResultSeverityTimestamp
@auditLog.Id@auditLog.IPAddress@auditLog.Description@auditLog.LogAction@auditLog.LogItem@auditLog.LogResult@auditLog.LogSeverity@auditLog.CreatedDate
42 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Groups/Create.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.WebUI.Constants 2 | @using Infrabot.WebUI.Models 3 | @model GroupViewModel 4 | @{ 5 | ViewData["Title"] = "Create a group"; 6 | } 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |

Create

15 | 16 |
17 |
18 | 19 | @if (ViewData[TempDataKeys.GroupAlreadyExists] as bool? == true) 20 | { 21 | 24 | } 25 | 26 |
27 |
28 |
29 | @Html.AntiForgeryToken() 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 | 38 |
39 | 40 | 41 | 42 |
43 |
44 | 45 |
46 | 47 | 48 | Cancel 49 |
50 |
51 |
52 | 53 |
54 |
55 | 56 | 67 | 68 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Groups/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @model Group 3 | @{ 4 | ViewData["Title"] = "Delete a group"; 5 | } 6 | 7 |
8 |
9 |

Delete

10 | 11 |
12 |
13 | 14 |

Are you sure that you want to delete user @Model.Name ?

15 | 16 |
17 | @Html.AntiForgeryToken() 18 | 19 | 20 | 21 | Cancel 22 |
23 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Groups/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.WebUI.Constants 2 | @using Infrabot.WebUI.Models 3 | @model GroupViewModel 4 | @{ 5 | ViewData["Title"] = "Edit a group"; 6 | } 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |

Edit

15 | 16 |
17 |
18 | 19 | @if (ViewData[TempDataKeys.GroupSaved] as bool? == true) 20 | { 21 | 24 | } 25 | 26 |
27 |
28 |
29 | @Html.AntiForgeryToken() 30 | 31 |
32 | 33 | 34 |
35 | 36 | 37 | 38 |
39 | 40 |
41 | 42 | 43 | 44 |
45 |
46 | 47 |
48 | 49 | 50 | Cancel 51 |
52 |
53 |
54 | 55 |
56 |
57 | 58 | 69 | 70 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Groups/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.WebUI.Constants 2 | @using Infrabot.Common.Models 3 | @model List 4 | @{ 5 | ViewData["Title"] = "Groups"; 6 | } 7 | 8 |
9 |
10 |

Groups

11 |
12 | 20 |
21 | 22 | @if (ViewData[TempDataKeys.GroupNotFound] as bool? == true) 23 | { 24 | 27 | } 28 | 29 | @if (ViewData[TempDataKeys.GroupDeleted] as bool? == true) 30 | { 31 | 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | @foreach (var group in Model) 45 | { 46 | 47 | 48 | 56 | 57 | } 58 | 59 |
Name#
@group.Name 49 | 50 | 51 | 52 | 53 | 54 | 55 |
60 | 61 | @if (ViewBag.Pages > 1) 62 | { 63 | 84 | } 85 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Home/Error404.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | 10 | 404 Page Not Found 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
404
22 |
Oops! The page you are looking for does not exist.
23 | Go Back Home 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Logs/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Logs"; 3 | } 4 | 5 | 6 | 7 |
8 |
9 | 10 | 11 |
12 | 13 |
@ViewBag.Logs
14 |
15 | 16 | 30 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Messages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @model List 3 | @{ 4 | ViewData["Title"] = "Messages"; 5 | } 6 | 7 |
8 |
9 |

Messages

10 |
11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | @foreach (var telegramMessage in Model) 24 | { 25 | 26 | 27 | 28 | 29 | 30 | 31 | } 32 | 33 |
TimestampTelegram user idTelegram usernameMessage
@telegramMessage.CreatedDate@telegramMessage.TelegramUserId@telegramMessage.TelegramUserUsername@telegramMessage.Message
34 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/PermissionAssignment/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @model PermissionAssignment 3 | @{ 4 | ViewData["Title"] = "Delete permission assignment"; 5 | } 6 | 7 |
8 |
9 |

Delete

10 | 11 |
12 |
13 | 14 |

Are you sure that you want to delete permission assignment @Model.Name ?

15 | 16 |
17 | @Html.AntiForgeryToken() 18 | 19 | 20 | 21 | Cancel 22 |
23 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Plugins/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @using Infrabot.WebUI.Constants 3 | @model Plugin 4 | @{ 5 | ViewData["Title"] = "Delete plugin"; 6 | } 7 | 8 |
9 |
10 |

Delete

11 | 12 |
13 |
14 | 15 | @if (ViewData[TempDataKeys.PluginDeleteFailed] as bool? == true) 16 | { 17 | 20 | } 21 | 22 |

Are you sure that you want to delete plugin @Model.Name ?

23 | 24 |
25 | @Html.AntiForgeryToken() 26 | 27 | 28 | 29 | Cancel 30 |
31 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Plugins/Upload.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.WebUI.Models 2 | @using Infrabot.WebUI.Constants 3 | @model UploadPluginViewModel 4 | @{ 5 | ViewData["Title"] = "Upload"; 6 | } 7 | 8 |
9 |
10 |

Upload plugin

11 |
12 |
13 | 14 | @if (ViewData[TempDataKeys.PluginUploaded] as bool? == true) 15 | { 16 | 19 | } 20 | 21 |
22 |
23 | @Html.AntiForgeryToken() 24 | 25 |
26 |
27 |
28 | 29 | 30 | 31 |
Please provide files.
32 |
33 |
34 | 35 | 36 |
37 |
38 |
39 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/TelegramUsers/Create.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @using Infrabot.WebUI.Constants 3 | @model TelegramUser 4 | @{ 5 | ViewData["Title"] = "Create a telegram user"; 6 | } 7 | 8 |
9 |
10 |

Create

11 | 12 |
13 |
14 | 15 | @if (ViewData[TempDataKeys.TelegramUserAlreadyExists] as bool? == true) 16 | { 17 | 20 | } 21 | 22 |
23 |
24 |
25 | @Html.AntiForgeryToken() 26 | 27 |
28 |
29 | 30 | 31 |
32 | Please provide the name of the user. 33 |
34 |
35 | 36 |
37 | 38 | 39 |
40 | Please provide the surname of the user. 41 |
42 |
43 | 44 |
45 | 46 | 47 |
48 | Please provide the telegram id. 49 |
50 |
51 |
52 | 53 | @if (ViewBag.TelegramUserAlreadyExists != null) 54 | { 55 | 58 | } 59 | 60 |
61 | 62 | 63 | Cancel 64 |
65 |
66 |
67 | 68 |
69 |
70 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/TelegramUsers/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @model TelegramUser 3 | @{ 4 | ViewData["Title"] = "Delete a telegram user"; 5 | } 6 | 7 |
8 |
9 |

Delete

10 | 11 |
12 |
13 | 14 |

Are you sure that you want to delete user @Model.Name @Model.Surname ?

15 | 16 |
17 | @Html.AntiForgeryToken() 18 | 19 | 20 | 21 | Cancel 22 |
23 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/TelegramUsers/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @using Infrabot.Common.Models 2 | @using Infrabot.WebUI.Constants 3 | @model TelegramUser 4 | @{ 5 | ViewData["Title"] = "Edit a telegram user"; 6 | } 7 | 8 |
9 |
10 |

Edit

11 | 12 |
13 |
14 | 15 | @if (ViewData[TempDataKeys.TelegramUserSaved] as bool? == true) 16 | { 17 | 20 | } 21 | 22 |
23 |
24 |
25 | @Html.AntiForgeryToken() 26 | 27 |
28 | 29 | 30 |
31 | 32 | 33 |
34 | Please provide the name of the user. 35 |
36 |
37 | 38 |
39 | 40 | 41 |
42 | Please provide the surname of the user. 43 |
44 |
45 | 46 |
47 | 48 | 49 |
50 | Please provide the telegram id. 51 |
52 |
53 |
54 | 55 |
56 | 57 | 58 | Cancel 59 |
60 |
61 |
62 | 63 |
64 |
65 | 66 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/Users/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model Infrabot.Common.Models.User 2 | @{ 3 | ViewData["Title"] = "Delete a user"; 4 | } 5 | 6 |
7 |
8 |

Delete

9 | 10 |
11 |
12 | 13 |

Are you sure that you want to delete user @Model.Name @Model.Surname ?

14 | 15 |
16 | @Html.AntiForgeryToken() 17 | 18 | 19 | 20 | Cancel 21 |
22 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using infrabot 2 | @using infrabot.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Infrabot.WebUI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Infrabot.WebUI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Debug", 10 | "Override": { 11 | "Microsoft": "Debug", 12 | "Microsoft.AspNetCore": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Debug", 14 | "Microsoft.EntityFrameworkCore.Database": "Warning", 15 | "System": "Debug" 16 | } 17 | }, 18 | "WriteTo": [ 19 | { 20 | "Name": "Debug" 21 | }, 22 | { 23 | "Name": "Console" 24 | }, 25 | { 26 | "Name": "File", 27 | "Args": { 28 | "path": "D:\\infrabot\\logs\\WebUI\\application-.log", 29 | "rollingInterval": "Day", 30 | "rollOnFileSizeLimit": true, 31 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 32 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 33 | } 34 | } 35 | ], 36 | "Enrich": [ 37 | "FromLogContext", 38 | "WithMachineName", 39 | "WithThreadId" 40 | ] 41 | }, 42 | "Kestrel": { 43 | "Endpoints": { 44 | "Http": { 45 | "Url": "http://0.0.0.0:80" 46 | }, 47 | "Https": { 48 | "Url": "https://0.0.0.0:8443" 49 | } 50 | }, 51 | "Certificates": { 52 | "Default": { 53 | "Path": "cert.pfx", 54 | "Password": "A123456a" 55 | } 56 | } 57 | }, 58 | "AllowedHosts": "*", 59 | "ConnectionStrings": { 60 | "DefaultConnection": "Data Source=D:\\infrabot\\database\\database.db;" 61 | }, 62 | "Plugins": { 63 | "PluginsDirectory": "D:\\infrabot\\plugins" 64 | }, 65 | "IdentityOptions": { 66 | "SignIn": { 67 | "RequireConfirmedEmail": false, 68 | "RequireConfirmedPhoneNumber": false 69 | }, 70 | "Lockout": { 71 | "DefaultLockoutTimeSpan": "5", 72 | "MaxFailedAccessAttempts": "5", 73 | "AllowedForNewUsers": true 74 | }, 75 | "Password": { 76 | "RequiredLength": 1, 77 | "RequireDigit": false, 78 | "RequiredUniqueChars": 0, 79 | "RequireLowercase": false, 80 | "RequireNonAlphanumeric": false, 81 | "RequireUppercase": false 82 | }, 83 | "User": { 84 | "AllowedUserNameCharacters": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._", 85 | "RequireUniqueEmail": true 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Infrabot.WebUI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Information", 10 | "Override": { 11 | "Microsoft": "Warning", 12 | "Microsoft.AspNetCore": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Warning", 14 | "Microsoft.EntityFrameworkCore.Database": "Warning", 15 | "System": "Warning" 16 | } 17 | }, 18 | "WriteTo": [ 19 | { 20 | "Name": "Debug" 21 | }, 22 | { 23 | "Name": "Console" 24 | }, 25 | { 26 | "Name": "File", 27 | "Args": { 28 | "path": "..\\logs\\WebUI\\application-.log", 29 | "rollingInterval": "Day", 30 | "rollOnFileSizeLimit": true, 31 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 32 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 33 | } 34 | } 35 | ], 36 | "Enrich": [ 37 | "FromLogContext", 38 | "WithMachineName", 39 | "WithThreadId" 40 | ] 41 | }, 42 | "Kestrel": { 43 | "Endpoints": { 44 | "Http": { 45 | "Url": "http://0.0.0.0:80" 46 | }, 47 | "Https": { 48 | "Url": "https://0.0.0.0:8443" 49 | } 50 | }, 51 | "Certificates": { 52 | "Default": { 53 | "Path": "cert.pfx", 54 | "Password": "A123456a" 55 | } 56 | } 57 | }, 58 | "AllowedHosts": "*", 59 | "ConnectionStrings": { 60 | "DefaultConnection": "Data Source=..\\database\\database.db;" 61 | }, 62 | "Plugins": { 63 | "PluginsDirectory": "..\\plugins" 64 | }, 65 | "IdentityOptions": { 66 | "SignIn": { 67 | "RequireConfirmedEmail": false, 68 | "RequireConfirmedPhoneNumber": false 69 | }, 70 | "Lockout": { 71 | "DefaultLockoutTimeSpan": "5", 72 | "MaxFailedAccessAttempts": "5", 73 | "AllowedForNewUsers": true 74 | }, 75 | "Password": { 76 | "RequiredLength": 1, 77 | "RequireDigit": false, 78 | "RequiredUniqueChars": 0, 79 | "RequireLowercase": false, 80 | "RequireNonAlphanumeric": false, 81 | "RequireUppercase": false 82 | }, 83 | "User": { 84 | "AllowedUserNameCharacters": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._", 85 | "RequireUniqueEmail": true 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Infrabot.WebUI/cert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/cert.pfx -------------------------------------------------------------------------------- /Infrabot.WebUI/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/icon.ico -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/css/error404.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #fff; 3 | color: #F75D55; 4 | font-family: 'Segoe UI', sans-serif; 5 | display: flex; 6 | justify-content: center; 7 | align-items: center; 8 | height: 100vh; 9 | margin: 0; 10 | overflow: hidden; 11 | } 12 | 13 | .error-container { 14 | text-align: center; 15 | } 16 | 17 | .error-code { 18 | font-size: 10rem; 19 | font-weight: bold; 20 | letter-spacing: -0.05em; 21 | } 22 | 23 | .error-text { 24 | font-size: 1.5rem; 25 | margin-bottom: 1.5rem; 26 | } 27 | 28 | .btn-home { 29 | font-size: 1rem; 30 | padding: 0.8rem 2rem; 31 | border-radius: 50px; 32 | background: #F75D55; 33 | color: #fff; 34 | border: none; 35 | transition: all 0.3s ease; 36 | } 37 | 38 | .btn-home:hover { 39 | background: #f75d5587; 40 | color: #fff; 41 | } 42 | 43 | .illustration { 44 | width: 100%; 45 | max-width: 400px; 46 | margin-top: 2rem; 47 | } 48 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/css/login.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-weight: 300; 3 | background: linear-gradient(135deg, #FFF0F0, #FFEAE7); 4 | min-height: 100vh; 5 | display: flex; 6 | justify-content: center; 7 | align-items: center; 8 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 9 | margin: 0; 10 | } 11 | /* Login card styling */ 12 | .login-card { 13 | background: #fff; 14 | padding: 2rem; 15 | border-radius: 12px; 16 | box-shadow: 0 4px 25px rgba(0, 0, 0, 0.1); 17 | width: 100%; 18 | max-width: 400px; 19 | } 20 | /* Logo: using the accent as background with a white "I" for InfraBot */ 21 | .logo { 22 | width: 100px; 23 | height: 100px; 24 | margin: 0 auto 1rem; 25 | background: url('../img/infrabot.png'); 26 | background-size: 100% auto; 27 | border-radius: 50%; 28 | } 29 | /* Title styling */ 30 | .login-title { 31 | text-align: center; 32 | font-size: 1.8rem; 33 | margin-bottom: 1rem; 34 | color: #333; 35 | } 36 | /* Input focus styling using the accent color (with a transparent overlay) */ 37 | .form-control:focus { 38 | border-color: #F75D55; 39 | box-shadow: 0 0 0 0.2rem rgba(247, 93, 85, 0.25); 40 | } 41 | /* Custom button styling with a slight darkening on hover */ 42 | .btn-custom { 43 | background: #F75D55; 44 | border: none; 45 | transition: background 0.3s ease; 46 | } 47 | 48 | .btn-custom:hover { 49 | background: #E64A45; 50 | } 51 | /* Version note styling */ 52 | .version { 53 | text-align: center; 54 | margin-top: 1rem; 55 | font-size: 0.85rem; 56 | color: #777; 57 | } 58 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/css/logs.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #f8f9fa !important; 3 | } 4 | 5 | #logContainer { 6 | overflow-y: auto; 7 | background: #212529; 8 | color: #fff; 9 | padding: 10px; 10 | font-family: monospace; 11 | border-radius: 5px; 12 | white-space: pre-wrap; 13 | } 14 | 15 | .highlight { 16 | background-color: yellow; 17 | color: black; 18 | font-weight: bold; 19 | } 20 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/add-multiple.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/clean.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ic_fluent_erase_24_regular 6 | Created with Sketch. 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/delete.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/contents/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/contents/1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/contents/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/contents/2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/contents/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/contents/3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/contents/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/contents/4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/contents/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/contents/5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example1_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example1_6.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example2_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example2_6.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_6.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example3_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example3_7.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example4_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example4_1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example4_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example4_2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example4_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example4_3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example4_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example4_4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example4_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example4_5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_6.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/examples/example5_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/examples/example5_7.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/1.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/2.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/3.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/4.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/5.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/6.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/documentation/gettingstarted/7.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/edit.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/export_white.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_configuration.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_documentation.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_groups.svg: -------------------------------------------------------------------------------- 1 | group-line -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_home.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_logs.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_messages.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_permission_assignments.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_plugins.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_telegram_users.svg: -------------------------------------------------------------------------------- 1 | telegram_line -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/icon_users.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/infrabot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WebUI/wwwroot/img/infrabot.png -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/messages.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/migrate.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/notifications.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/profile.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/refresh.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/start_task.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/test.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/view.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/img/warning.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/highlight-js/dist/css/default.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | Theme: Default 3 | Description: Original highlight.js style 4 | Author: (c) Ivan Sagalaev 5 | Maintainer: @highlightjs/core-team 6 | Website: https://highlightjs.org/ 7 | License: see project LICENSE 8 | Touched: 2021 9 | */pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700} -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/highlight-js/dist/css/vs2015.min.css: -------------------------------------------------------------------------------- 1 | .hljs{display:block;overflow-x:auto;padding:0.5em;background:#1E1E1E;color:#DCDCDC}.hljs-keyword,.hljs-literal,.hljs-symbol,.hljs-name{color:#569CD6}.hljs-link{color:#569CD6;text-decoration:underline}.hljs-built_in,.hljs-type{color:#4EC9B0}.hljs-number,.hljs-class{color:#B8D7A3}.hljs-string,.hljs-meta-string{color:#D69D85}.hljs-regexp,.hljs-template-tag{color:#9A5334}.hljs-subst,.hljs-function,.hljs-title,.hljs-params,.hljs-formula{color:#DCDCDC}.hljs-comment,.hljs-quote{color:#57A64A;font-style:italic}.hljs-doctag{color:#608B4E}.hljs-meta,.hljs-meta-keyword,.hljs-tag{color:#9B9B9B}.hljs-variable,.hljs-template-variable{color:#BD63C5}.hljs-attr,.hljs-attribute,.hljs-builtin-name{color:#9CDCFE}.hljs-section{color:gold}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}.hljs-bullet,.hljs-selector-tag,.hljs-selector-id,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo{color:#D7BA7D}.hljs-addition{background-color:#144212;display:inline-block;width:100%}.hljs-deletion{background-color:#600;display:inline-block;width:100%} -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Infrabot.WebUI/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Infrabot.WorkerService/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Serilog; 2 | 3 | namespace Infrabot.WorkerService.Extensions 4 | { 5 | public static class ServiceCollectionExtensions 6 | { 7 | public static IServiceCollection AddInfrabotServices(this IServiceCollection services) 8 | { 9 | // Register services related to the Item API 10 | services.AddHostedService(); 11 | services.AddHostedService(); 12 | services.AddHostedService(); 13 | 14 | // Return the IServiceCollection for method chaining 15 | return services; 16 | } 17 | 18 | public static IServiceCollection AddInfrabotLogging(this IServiceCollection services) 19 | { 20 | // Register services related to the Item API 21 | var configuration = new ConfigurationBuilder() 22 | .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) 23 | .AddJsonFile("appsettings.json") 24 | .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true) 25 | .Build(); 26 | 27 | Log.Logger = new LoggerConfiguration() 28 | .ReadFrom.Configuration(configuration) 29 | .CreateLogger(); 30 | 31 | services.AddSerilog(); 32 | 33 | //builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); 34 | //builder.Logging.AddConsole(); 35 | //builder.Logging.AddEventLog(); 36 | 37 | // Return the IServiceCollection for method chaining 38 | return services; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/Infrabot.WorkerService.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | dotnet-Infrabot.WorkerService-1c7dc8fc-583b-4d91-8505-2e472577535c 8 | icon.ico 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/Program.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.Common.Contexts; 2 | using Infrabot.WorkerService.Extensions; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | var builder = Host.CreateApplicationBuilder(args); 6 | 7 | /*****************************************/ 8 | /* Add database connection */ 9 | builder.Services.AddDbContext(options => options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"))); 10 | 11 | /*****************************************/ 12 | /* Add services */ 13 | builder.Services.AddWindowsService(options => { options.ServiceName = "Infrabot Worker Service"; }); 14 | builder.Services.AddInfrabotLogging(); 15 | builder.Services.AddInfrabotServices(); 16 | 17 | var host = builder.Build(); 18 | host.Run(); 19 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "Infrabot.WorkerService": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "environmentVariables": { 8 | "DOTNET_ENVIRONMENT": "Development" 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Debug", 10 | "Override": { 11 | "Microsoft": "Debug", 12 | "Microsoft.AspNetCore": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Debug", 14 | "Microsoft.EntityFrameworkCore.Database": "Warning", 15 | "System": "Debug" 16 | } 17 | }, 18 | "WriteTo": [ 19 | { 20 | "Name": "Debug" 21 | }, 22 | { 23 | "Name": "Console" 24 | }, 25 | { 26 | "Name": "File", 27 | "Args": { 28 | "path": "D:\\infrabot\\logs\\WorkerService\\application-.log", 29 | "rollingInterval": "Day", 30 | "rollOnFileSizeLimit": true, 31 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 32 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 33 | } 34 | } 35 | ], 36 | "Enrich": [ 37 | "FromLogContext", 38 | "WithMachineName", 39 | "WithThreadId" 40 | ] 41 | }, 42 | "ConnectionStrings": { 43 | "DefaultConnection": "Data Source=D:\\infrabot\\database\\database.db;" 44 | }, 45 | "Services": { 46 | "HealthCheckerIntervalMinutes": 10, 47 | "HealthDataCleanerIntervalMinutes": 720, 48 | "HealthDataCleanerKeepLastDays": 7, 49 | "MessageCleanerIntervalMinutes": 720, 50 | "MessageCleanerKeepLastDays": 7 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ 4 | "Serilog.Sinks.Console", 5 | "Serilog.Sinks.File", 6 | "Serilog.Sinks.Debug" 7 | ], 8 | "MinimumLevel": { 9 | "Default": "Information", 10 | "Override": { 11 | "Microsoft": "Warning", 12 | "Microsoft.AspNetCore": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Warning", 14 | "Microsoft.EntityFrameworkCore.Database": "Warning", 15 | "System": "Warning" 16 | } 17 | }, 18 | "WriteTo": [ 19 | { 20 | "Name": "Debug" 21 | }, 22 | { 23 | "Name": "Console" 24 | }, 25 | { 26 | "Name": "File", 27 | "Args": { 28 | "path": "..\\logs\\WorkerService\\application-.log", 29 | "rollingInterval": "Day", 30 | "rollOnFileSizeLimit": true, 31 | "formatter": "Serilog.Formatting.Json.JsonFormatter", 32 | "_outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" 33 | } 34 | } 35 | ], 36 | "Enrich": [ 37 | "FromLogContext", 38 | "WithMachineName", 39 | "WithThreadId" 40 | ] 41 | }, 42 | "ConnectionStrings": { 43 | "DefaultConnection": "Data Source=..\\database\\database.db;" 44 | }, 45 | "Services": { 46 | "HealthCheckerIntervalMinutes": 10, 47 | "HealthDataCleanerIntervalMinutes": 720, 48 | "HealthDataCleanerKeepLastDays": 7, 49 | "MessageCleanerIntervalMinutes": 720, 50 | "MessageCleanerKeepLastDays": 7 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Infrabot.WorkerService/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Infrabot.WorkerService/icon.ico -------------------------------------------------------------------------------- /Setup/InfrabotSetup.iss: -------------------------------------------------------------------------------- 1 | #include "CodeDependencies.iss" 2 | 3 | [Setup] 4 | AppName=infrabot 5 | AppVersion=3.0.0.0 6 | WizardStyle=modern 7 | DefaultDirName={autopf}\infrabot\3_0_0_0\ 8 | DefaultGroupName=InfraBot 9 | UninstallDisplayIcon={app}\WebUI\Infrabot.WebUI.exe 10 | Compression=lzma2 11 | SolidCompression=yes 12 | OutputDir=".\" 13 | OutputBaseFilename="infrabot_3_0_0_0_full_install" 14 | ArchitecturesInstallIn64BitMode=x64 15 | PrivilegesRequired=admin 16 | 17 | [Files] 18 | Source: ".\files\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 19 | 20 | [Icons] 21 | Name: "{group}\InfraBot Plugin Editor"; Filename: "{app}\PluginEditor\infrabot.PluginEditor.exe" 22 | Name: "{group}\Infrabot Admin Panel"; Filename: "http://localhost/" 23 | Name: "{userdesktop}\InfraBot Plugin Editor"; Filename: "{app}\PluginEditor\infrabot.PluginEditor.exe"; IconFilename: "{app}\PluginEditor\infrabot.PluginEditor.exe" 24 | Name: "{autodesktop}\Infrabot Admin Panel"; Filename: "http://localhost/" 25 | 26 | [Run] 27 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotWebUI" ; Flags: runhidden 28 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "install InfrabotWebUI ""{app}\WebUI\Infrabot.WebUI.exe""" ; Flags: runhidden 29 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "set InfrabotWebUI AppDirectory ""{app}\WebUI""" ; Flags: runhidden 30 | 31 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotTelegramService" ; Flags: runhidden 32 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "install InfrabotTelegramService ""{app}\TelegramService\Infrabot.TelegramService.exe""" ; Flags: runhidden 33 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "set InfrabotTelegramService AppDirectory ""{app}\TelegramService""" ; Flags: runhidden 34 | 35 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotWorkerService" ; Flags: runhidden 36 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "install InfrabotWorkerService ""{app}\WorkerService\Infrabot.WorkerService.exe""" ; Flags: runhidden 37 | Filename: {app}\nssm-2.24\win64\nssm.exe; Parameters: "set InfrabotWorkerService AppDirectory ""{app}\WorkerService""" ; Flags: runhidden 38 | 39 | Filename: {sys}\sc.exe; Parameters: "start InfrabotWebUI" ; Flags: runhidden 40 | Filename: {sys}\sc.exe; Parameters: "start InfrabotWorkerService" ; Flags: runhidden 41 | 42 | [UninstallRun] 43 | Filename: {sys}\sc.exe; Parameters: "stop InfrabotWebUI" ; Flags: runhidden 44 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotWebUI" ; Flags: runhidden 45 | Filename: {sys}\sc.exe; Parameters: "stop InfrabotTelegramService" ; Flags: runhidden 46 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotTelegramService" ; Flags: runhidden 47 | Filename: {sys}\sc.exe; Parameters: "stop InfrabotWorkerService" ; Flags: runhidden 48 | Filename: {sys}\sc.exe; Parameters: "delete InfrabotWorkerService" ; Flags: runhidden 49 | 50 | [Code] 51 | 52 | function InitializeSetup(): Boolean; 53 | begin 54 | Dependency_AddDotNet80Asp; 55 | Dependency_AddDotNet80Desktop; 56 | Result := True; 57 | end; 58 | -------------------------------------------------------------------------------- /Setup/InfrabotSetupPluginEditor.iss: -------------------------------------------------------------------------------- 1 | #include "CodeDependencies.iss" 2 | 3 | [Setup] 4 | AppName=infrabot Plugin Editor 5 | AppVersion=3.0.0.0 6 | WizardStyle=modern 7 | DefaultDirName={autopf}\infrabot\3_0_0_0\ 8 | DefaultGroupName=InfraBot 9 | UninstallDisplayIcon={app}\PluginEditor\infrabot.PluginEditor.exe 10 | Compression=lzma2 11 | SolidCompression=yes 12 | OutputDir=".\" 13 | OutputBaseFilename="infrabot_3_0_0_0_PluginEditor_install" 14 | ArchitecturesInstallIn64BitMode=x64 15 | PrivilegesRequired=admin 16 | 17 | [Files] 18 | Source: ".\files\PluginEditor\*"; DestDir: "{app}\PluginEditor\"; Flags: ignoreversion recursesubdirs createallsubdirs 19 | 20 | [Icons] 21 | Name: "{group}\InfraBot Plugin Editor"; Filename: "{app}\PluginEditor\infrabot.PluginEditor.exe" 22 | Name: "{userdesktop}\InfraBot Plugin Editor"; Filename: "{app}\PluginEditor\infrabot.PluginEditor.exe"; IconFilename: "{app}\PluginEditor\infrabot.PluginEditor.exe" 23 | 24 | [Code] 25 | 26 | function InitializeSetup(): Boolean; 27 | begin 28 | Dependency_AddDotNet80Desktop; 29 | Result := True; 30 | end; 31 | -------------------------------------------------------------------------------- /Setup/files/Examples/AzureADSync.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/Examples/AzureADSync.plug -------------------------------------------------------------------------------- /Setup/files/Examples/GetServiceStatus.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/Examples/GetServiceStatus.plug -------------------------------------------------------------------------------- /Setup/files/Examples/ManageActiveDirectory.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/Examples/ManageActiveDirectory.plug -------------------------------------------------------------------------------- /Setup/files/Examples/ManageBitLocker.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/Examples/ManageBitLocker.plug -------------------------------------------------------------------------------- /Setup/files/Examples/RestartServer.plug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/Examples/RestartServer.plug -------------------------------------------------------------------------------- /Setup/files/PluginEditor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/PluginEditor/.gitkeep -------------------------------------------------------------------------------- /Setup/files/TelegramService/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/TelegramService/.gitkeep -------------------------------------------------------------------------------- /Setup/files/WebUI/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/WebUI/.gitkeep -------------------------------------------------------------------------------- /Setup/files/WorkerService/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/WorkerService/.gitkeep -------------------------------------------------------------------------------- /Setup/files/database/database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/database/database.db-shm -------------------------------------------------------------------------------- /Setup/files/database/database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/database/database.db-wal -------------------------------------------------------------------------------- /Setup/files/logs/TelegramService/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/logs/TelegramService/.gitkeep -------------------------------------------------------------------------------- /Setup/files/logs/WebUI/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/logs/WebUI/.gitkeep -------------------------------------------------------------------------------- /Setup/files/logs/WorkerService/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/logs/WorkerService/.gitkeep -------------------------------------------------------------------------------- /Setup/files/nssm-2.24/win32/nssm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/nssm-2.24/win32/nssm.exe -------------------------------------------------------------------------------- /Setup/files/nssm-2.24/win64/nssm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/nssm-2.24/win64/nssm.exe -------------------------------------------------------------------------------- /Setup/files/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/Setup/files/plugins/.gitkeep -------------------------------------------------------------------------------- /assets/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/1.PNG -------------------------------------------------------------------------------- /assets/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/2.PNG -------------------------------------------------------------------------------- /assets/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/3.PNG -------------------------------------------------------------------------------- /assets/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/4.PNG -------------------------------------------------------------------------------- /assets/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/5.PNG -------------------------------------------------------------------------------- /assets/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/6.PNG -------------------------------------------------------------------------------- /assets/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/7.PNG -------------------------------------------------------------------------------- /assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/demo.gif -------------------------------------------------------------------------------- /assets/footer_fixed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /assets/header.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | infrabot 37 | control your infrastructure using a Telegram Bot 38 | 39 | -------------------------------------------------------------------------------- /assets/infrabot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/assets/infrabot.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Data; 3 | using System.Windows; 4 | 5 | namespace Infrabot.PluginEditor 6 | { 7 | /// 8 | /// Interaction logic for App.xaml 9 | /// 10 | public partial class App : Application 11 | { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/about.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/add.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/close.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/exit.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/export.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/github.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/help.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/i.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/i.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/icon.ico -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/import.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/newfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/newfile.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/openfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/openfile.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/remove.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/Images/save.png -------------------------------------------------------------------------------- /infrabot.PluginEditor/Notifiers/ExecutionFileArgumentWrapper.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Execution; 2 | using System.ComponentModel; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace Infrabot.PluginEditor.Notifiers 6 | { 7 | public class ExecutionFileArgumentWrapper : INotifyPropertyChanged 8 | { 9 | private readonly ExecutionFileArgument _argument; 10 | public ExecutionFileArgument OriginalArgument => _argument; 11 | 12 | public event PropertyChangedEventHandler? PropertyChanged; 13 | 14 | public ExecutionFileArgumentWrapper(ExecutionFileArgument argument) 15 | { 16 | _argument = argument; 17 | } 18 | 19 | public string Name 20 | { 21 | get => _argument.Name; 22 | set 23 | { 24 | if (_argument.Name != value) 25 | { 26 | _argument.Name = value; 27 | OnPropertyChanged(); 28 | } 29 | } 30 | } 31 | 32 | public string? Value 33 | { 34 | get => _argument.Value; 35 | set 36 | { 37 | if (_argument.Value != value) 38 | { 39 | _argument.Value = value; 40 | OnPropertyChanged(); 41 | } 42 | } 43 | } 44 | 45 | public string? Description 46 | { 47 | get => _argument.Description; 48 | set 49 | { 50 | if (_argument.Description != value) 51 | { 52 | _argument.Description = value; 53 | OnPropertyChanged(); 54 | } 55 | } 56 | } 57 | 58 | protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) 59 | { 60 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Notifiers/PluginSettingWrapper.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Enums; 2 | using Infrabot.PluginSystem.Execution; 3 | using System.ComponentModel; 4 | using System.Runtime.CompilerServices; 5 | 6 | namespace Infrabot.PluginEditor.Notifiers 7 | { 8 | public class PluginSettingWrapper : INotifyPropertyChanged 9 | { 10 | private readonly PluginSetting _setting; 11 | public PluginSetting OriginalSetting => _setting; 12 | 13 | public event PropertyChangedEventHandler? PropertyChanged; 14 | 15 | public PluginSettingWrapper(PluginSetting setting) 16 | { 17 | _setting = setting; 18 | } 19 | 20 | public string Key 21 | { 22 | get => _setting.Key; 23 | set 24 | { 25 | if (_setting.Key != value) 26 | { 27 | _setting.Key = value; 28 | OnPropertyChanged(); 29 | } 30 | } 31 | } 32 | 33 | public string Value 34 | { 35 | get => _setting.Value; 36 | set 37 | { 38 | if (_setting.Value != value) 39 | { 40 | _setting.Value = value; 41 | OnPropertyChanged(); 42 | } 43 | } 44 | } 45 | 46 | public PluginSettingType SettingType 47 | { 48 | get => _setting.SettingType; 49 | set 50 | { 51 | if (_setting.SettingType != value) 52 | { 53 | _setting.SettingType = value; 54 | OnPropertyChanged(); 55 | } 56 | } 57 | } 58 | 59 | public string Description 60 | { 61 | get => _setting.Description; 62 | set 63 | { 64 | if (_setting.Description != value) 65 | { 66 | _setting.Description = value; 67 | OnPropertyChanged(); 68 | } 69 | } 70 | } 71 | 72 | protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) 73 | { 74 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Utils/CommonUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Windows; 5 | 6 | namespace Infrabot.PluginEditor.Utils 7 | { 8 | public static class CommonUtils 9 | { 10 | public static void OpenLinkInBrowser(string url) 11 | { 12 | try 13 | { 14 | Process proc = new Process(); 15 | proc.StartInfo.UseShellExecute = true; 16 | proc.StartInfo.FileName = url; 17 | proc.Start(); 18 | } 19 | catch (Exception ex) { MessageBox.Show(ex.Message); } 20 | } 21 | 22 | public static string ReadDocumentationFile() 23 | { 24 | var assembly = Assembly.GetExecutingAssembly(); 25 | string resourcePath = assembly.GetManifestResourceNames() 26 | .Single(str => str.EndsWith(@"PluginEditor.Documentation.HelpDocumentation.xml")); 27 | 28 | Stream? stream = assembly.GetManifestResourceStream(resourcePath); 29 | StreamReader? reader = new StreamReader(stream); 30 | return reader.ReadToEnd(); 31 | } 32 | 33 | public static string ReadLicenseFile() 34 | { 35 | var assembly = Assembly.GetExecutingAssembly(); 36 | string resourcePath = assembly.GetManifestResourceNames() 37 | .Single(str => str.EndsWith(@"PluginEditor.LICENSE.txt")); 38 | 39 | Stream? stream = assembly.GetManifestResourceStream(resourcePath); 40 | StreamReader? reader = new StreamReader(stream); 41 | return reader.ReadToEnd(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Windows/AboutDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Windows; 3 | using Infrabot.PluginEditor.Utils; 4 | 5 | namespace Infrabot.PluginEditor.Windows 6 | { 7 | /// 8 | /// Interaction logic for AboutDialog.xaml 9 | /// 10 | public partial class AboutDialog : Window 11 | { 12 | public AboutDialog() 13 | { 14 | InitializeComponent(); 15 | LoadDataInfoIntoTheForm(); 16 | } 17 | 18 | public void LoadDataInfoIntoTheForm() 19 | { 20 | AboutTitle.Content = "Infrabot Plugin Editor " + Assembly.GetExecutingAssembly().GetName().Version?.ToString(); 21 | AboutInfo.Content = "Author: Akshin Mustafayev"; 22 | LicenseText.Text = CommonUtils.ReadLicenseFile(); 23 | } 24 | 25 | private void GetInspirationButton_Click(object sender, RoutedEventArgs e) 26 | { 27 | CommonUtils.OpenLinkInBrowser("https://www.youtube.com/watch?v=l0U7SxXHkPY"); 28 | } 29 | 30 | private void CheckNewReleasesButton_Click(object sender, RoutedEventArgs e) 31 | { 32 | CommonUtils.OpenLinkInBrowser("https://github.com/infrabot-io/infrabot/releases"); 33 | } 34 | 35 | private void GithubImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 36 | { 37 | CommonUtils.OpenLinkInBrowser("https://github.com/infrabot-io/infrabot"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Windows/HelpDialog.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/Windows/HelpDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginEditor.Utils; 2 | using System.Windows; 3 | using System.Xml; 4 | 5 | namespace Infrabot.PluginEditor.Windows 6 | { 7 | /// 8 | /// Interaction logic for HelpDialog.xaml 9 | /// 10 | public partial class HelpDialog : Window 11 | { 12 | public HelpDialog(string helpitem) 13 | { 14 | InitializeComponent(); 15 | LoadXml(helpitem); 16 | } 17 | 18 | private void LoadXml(string helpitem) 19 | { 20 | XmlDocument doc = new XmlDocument(); 21 | doc.LoadXml(CommonUtils.ReadDocumentationFile()); 22 | 23 | if (doc is null) 24 | return; 25 | 26 | XmlNodeList nodeList = doc.SelectNodes("/items/item[name='" + helpitem + "']"); 27 | 28 | HelpHeading.Text = nodeList[0]["heading"].InnerText; 29 | HelpUsed.Text = nodeList[0]["used"].InnerText; 30 | HelpDescription.Text = nodeList[0]["description"].InnerText; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabot-io/infrabot/354f70808bd61dcdaa3f4660758b820199ca5768/infrabot.PluginEditor/icon.ico -------------------------------------------------------------------------------- /infrabot.PluginEditor/infrabot.PluginEditor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net8.0-windows 6 | enable 7 | enable 8 | true 9 | icon.ico 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /infrabot.PluginEditor/infrabot.PluginEditor.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Designer 7 | 8 | 9 | 10 | 11 | Code 12 | 13 | 14 | Code 15 | 16 | 17 | Code 18 | 19 | 20 | Code 21 | 22 | 23 | Code 24 | 25 | 26 | 27 | 28 | Designer 29 | 30 | 31 | Designer 32 | 33 | 34 | Designer 35 | 36 | 37 | Designer 38 | 39 | 40 | Designer 41 | 42 | 43 | Designer 44 | 45 | 46 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Data/PluginFile.cs: -------------------------------------------------------------------------------- 1 | using ProtoBuf; 2 | 3 | namespace Infrabot.PluginSystem.Data 4 | { 5 | [ProtoContract] 6 | public class PluginFile 7 | { 8 | [ProtoMember(1)] 9 | public string FileName { get; set; } // File name 10 | 11 | [ProtoMember(2)] 12 | public string FilePath { get; set; } // Path within the plugin's directory 13 | 14 | [ProtoMember(3)] 15 | public string FileHash { get; set; } // File hash 16 | 17 | [ProtoMember(4)] 18 | public byte[] FileData { get; set; } // File content 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Enums/CommandExecuteTypes.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.PluginSystem.Enums 2 | { 3 | public enum CommandExecuteTypes 4 | { 5 | AppExecutable = 0, // Executable file 6 | PSScript = 1, // PowerShell script 7 | CSharpScript = 2, // C# script (in-memory) 8 | BashScript = 3, // Bash script 9 | PythonScript = 4 // Python script 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Enums/PluginSettingType.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.PluginSystem.Enums 2 | { 3 | public enum PluginSettingType 4 | { 5 | EnvironmentVariable = 0, 6 | Argument = 1, 7 | ConfigFile = 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Enums/PluginType.cs: -------------------------------------------------------------------------------- 1 | namespace Infrabot.PluginSystem.Enums 2 | { 3 | public enum PluginType 4 | { 5 | Monitoring = 0, 6 | Alerting = 1, 7 | Logging = 2, 8 | Automation = 3, 9 | Infrastructure = 4, 10 | Configuration = 5, 11 | Administration = 6, 12 | ComplianceAndAudit = 7, 13 | Other = 8 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Execution/ExecutionFileArgument.cs: -------------------------------------------------------------------------------- 1 | using ProtoBuf; 2 | namespace Infrabot.PluginSystem.Execution 3 | { 4 | [ProtoContract] 5 | public class ExecutionFileArgument 6 | { 7 | [ProtoMember(1)] 8 | public string Name { get; set; } // Name or key of the argument 9 | 10 | [ProtoMember(2)] 11 | public string? Value { get; set; } // Value of the argument, can be templated 12 | 13 | [ProtoMember(3)] 14 | public string? Description { get; set; } = string.Empty; // Description 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Execution/PluginExecution.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Enums; 2 | using ProtoBuf; 3 | 4 | namespace Infrabot.PluginSystem.Execution 5 | { 6 | [ProtoContract] 7 | public class PluginExecution 8 | { 9 | [ProtoMember(1)] 10 | public string CommandName { get; set; } // Name of the command executed by the plugin 11 | 12 | [ProtoMember(2)] 13 | public string? Help { get; set; } = string.Empty; // Show help information about command 14 | 15 | [ProtoMember(3)] 16 | public string ExecutionFilePath { get; set; } // Path to the executable/script 17 | 18 | [ProtoMember(4)] 19 | public int ExecutionTimeout { get; set; } = 10; // Default timeout in seconds 20 | 21 | [ProtoMember(5)] 22 | public string? DefaultErrorMessage { get; set; } // Default error message 23 | 24 | [ProtoMember(6)] 25 | public CommandExecuteTypes ExecuteType { get; set; } // Type of execution (e.g., script, binary) 26 | 27 | [ProtoMember(7)] 28 | public List? ExecutionFileArguments { get; set; } = new(); // Dynamic argument logic 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Execution/PluginSetting.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Enums; 2 | using ProtoBuf; 3 | 4 | namespace Infrabot.PluginSystem.Execution 5 | { 6 | [ProtoContract] 7 | public class PluginSetting 8 | { 9 | [ProtoMember(1)] 10 | public string Key { get; set; } // Setting name 11 | 12 | [ProtoMember(2)] 13 | public string Value { get; set; } // Setting value 14 | 15 | [ProtoMember(3)] 16 | public PluginSettingType SettingType { get; set; } // Setting type 17 | 18 | [ProtoMember(4)] 19 | public string Description { get; set; } // Description of the setting 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Plugin.cs: -------------------------------------------------------------------------------- 1 | using Infrabot.PluginSystem.Data; 2 | using Infrabot.PluginSystem.Enums; 3 | using Infrabot.PluginSystem.Execution; 4 | using ProtoBuf; 5 | 6 | namespace Infrabot.PluginSystem 7 | { 8 | [ProtoContract] 9 | public class Plugin 10 | { 11 | [ProtoMember(1)] 12 | public Guid Guid { get; set; } // Plugin GUID 13 | 14 | [ProtoMember(2)] 15 | public string Id { get; set; } // Plugin ID, used to specify from the chat 16 | 17 | [ProtoMember(3)] 18 | public string Name { get; set; } // Plugin name 19 | 20 | [ProtoMember(4)] 21 | public string? Description { get; set; } = string.Empty; // Description 22 | 23 | [ProtoMember(5)] 24 | public PluginType PluginType { get; set; } // Type of the plugin 25 | 26 | [ProtoMember(6)] 27 | public string? Author { get; set; } = string.Empty; // Author name 28 | 29 | [ProtoMember(7)] 30 | public int Version { get; set; } = 0; // Plugin version 31 | 32 | [ProtoMember(8)] 33 | public string? WebSite { get; set; } = string.Empty; // WebSite url of the author 34 | 35 | [ProtoMember(9)] 36 | public List PluginExecutions { get; set; } = new(); // List of commands which infrabot reacts to 37 | 38 | [ProtoMember(10)] 39 | public List PluginFiles { get; set; } // List of embed plugin files 40 | 41 | [ProtoMember(11)] 42 | public List? Settings { get; set; } = new(); // Configurable plugin settings 43 | 44 | [ProtoMember(12)] 45 | public string Checksum { get; set; } // Plugin checksum to check against attacks 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Utils/EncryptionUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | 4 | namespace Infrabot.PluginSystem.Utils 5 | { 6 | public static class EncryptionUtility 7 | { 8 | public static string TripleDesEncrypt(string key, string text) 9 | { 10 | byte[] inputBytes = Encoding.UTF8.GetBytes(text); 11 | byte[] keyBytes = GetFixedLengthKey(key); 12 | 13 | using (TripleDES tripleDES = TripleDES.Create()) 14 | { 15 | tripleDES.Key = keyBytes; 16 | tripleDES.Mode = CipherMode.ECB; 17 | tripleDES.Padding = PaddingMode.PKCS7; 18 | 19 | using ICryptoTransform encryptor = tripleDES.CreateEncryptor(); 20 | byte[] encryptedBytes = encryptor.TransformFinalBlock(inputBytes, 0, inputBytes.Length); 21 | return Convert.ToBase64String(encryptedBytes); 22 | } 23 | } 24 | 25 | public static string TripleDesDecrypt(string key, string base64Text) 26 | { 27 | byte[] encryptedBytes = Convert.FromBase64String(base64Text); 28 | byte[] keyBytes = GetFixedLengthKey(key); 29 | 30 | using (TripleDES tripleDES = TripleDES.Create()) 31 | { 32 | tripleDES.Key = keyBytes; 33 | tripleDES.Mode = CipherMode.ECB; 34 | tripleDES.Padding = PaddingMode.PKCS7; 35 | 36 | using ICryptoTransform decryptor = tripleDES.CreateDecryptor(); 37 | byte[] decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length); 38 | return Encoding.UTF8.GetString(decryptedBytes); 39 | } 40 | } 41 | 42 | private static byte[] GetFixedLengthKey(string key) 43 | { 44 | // TripleDES requires a key of 16 or 24 bytes 45 | byte[] keyBytes = Encoding.UTF8.GetBytes(key); 46 | if (keyBytes.Length < 24) 47 | { 48 | Array.Resize(ref keyBytes, 24); // pad with zeros 49 | } 50 | else if (keyBytes.Length > 24) 51 | { 52 | Array.Resize(ref keyBytes, 24); // trim to 24 53 | } 54 | return keyBytes; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/Utils/HashUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | 4 | namespace Infrabot.PluginSystem.Utils 5 | { 6 | public static class HashUtility 7 | { 8 | public static string CalculateSHA256(string filename) 9 | { 10 | if (!File.Exists(filename)) 11 | return "file_does_not_exist"; 12 | 13 | using (FileStream stream = File.OpenRead(filename)) 14 | { 15 | using (SHA256 sha256 = SHA256.Create()) 16 | { 17 | StringBuilder hash = new StringBuilder(); 18 | byte[] checksum = sha256.ComputeHash(stream); 19 | return BitConverter.ToString(checksum).Replace("-", String.Empty); 20 | } 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /infrabot.PluginSystem/infrabot.PluginSystem.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /scheme.txt: -------------------------------------------------------------------------------- 1 | 2 | +--------------------------+ +------------------------+ +------------------------+ 3 | | Web Admin Service | | Telegram Service | | Worker Service | 4 | | - Web UI | | - Telegram Client | | - Health Checker | 5 | | - User/Group Mgmt | | - Plugin Manager | | - Health Data Cleaner | 6 | | - Plugin Access Mgmt | | - Command Manager | | - Message Cleaner | 7 | | - AD Auth Integration | | | | | 8 | | | | | | | 9 | +--------------------------+ +------------------------+ +------------------------+ 10 | | | | 11 | +-----------------------------------+------------------------------------+ 12 | | SQLite Database | 13 | | - Users, Groups, Plugins, Permissions, Health, Logs, Audit events | 14 | +------------------------------------------------------------------------+ 15 | 16 | --------------------------------------------------------------------------------