MoodyApi 1.0.0
See the version list below for details.
dotnet add package MoodyApi --version 1.0.0
NuGet\Install-Package MoodyApi -Version 1.0.0
<PackageReference Include="MoodyApi" Version="1.0.0" />
<PackageVersion Include="MoodyApi" Version="1.0.0" />
<PackageReference Include="MoodyApi" />
paket add MoodyApi --version 1.0.0
#r "nuget: MoodyApi, 1.0.0"
#:package MoodyApi@1.0.0
#addin nuget:?package=MoodyApi&version=1.0.0
#tool nuget:?package=MoodyApi&version=1.0.0
MoodyApi
MoodyApi is a modern, extensible .NET library designed to generate context-aware, mood-based messages for your applications and APIs. With seamless Dependency Injection support and ASP.NET Core middleware integration, MoodyApi helps you deliver engaging, dynamic responses tailored to user sentiment, system state, or business logic.
Table of Contents
- Features
- Installation
- Getting Started
- ASP.NET Core Middleware
- Configuration
- Advanced Usage: Custom Providers
- License
- Support & Contributing
Features
- Multiple built-in moods: Neutral, Motivational, Sarcastic, Karma-Based, Time-Based, Error-Based
- Extensible provider model: Easily add your own custom moods and message logic
- User-based karma tracking: Personalize responses based on user activity
- Flexible configuration: Fine-tune behavior via DI or appsettings
- ASP.NET Core middleware: Effortlessly wrap API responses with mood data
- Comprehensive test coverage
Installation
Install from NuGet:
Install-Package MoodyApi
Or using the .NET CLI:
dotnet add package MoodyApi
Getting Started
1. Register MoodyApi Services
using MoodyApi.Extensions;
var services = new ServiceCollection();
services.AddMoodyApi(options =>
{
options.Mode = MoodType.Motivational;
options.EnableSarcasm = false;
});
var serviceProvider = services.BuildServiceProvider();
// Initialize the static API
MoodyApi.Mood.Initialize(serviceProvider);
2. Generate Mood-Based Messages
using MoodyApi.Models;
// Get a random message for a specific mood
global::MoodyApi.Models.MoodType mood = MoodType.Sarcastic;
string message = MoodyApi.Mood.Get(mood);
// Get a detailed mood response (with optional user tracking)
var response = MoodyApi.Mood.GetResponse(mood, userId: "user-123");
ASP.NET Core Middleware
Seamlessly wrap your API responses with mood data:
using MoodyApi.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMoodyApi();
var app = builder.Build();
MoodyApi.Mood.Initialize(app.Services);
app.UseMoodyApi();
app.MapGet("/hello", () => new { message = "Hello World" });
app.Run();
The middleware will automatically inject mood information into every HTTP response.
Configuration
Configure MoodyApi via DI:
services.AddMoodyApi(options =>
{
options.Mode = MoodType.KarmaBased;
options.KarmaThreshold = 10;
options.EnableMotivation = true;
});
Or bind from appsettings.json
using your own configuration logic.
Advanced Usage: Custom Providers
You can extend MoodyApi by implementing your own message provider:
using MoodyApi.Providers.Interfaces;
using MoodyApi.Models;
public class CustomExcitedProvider : IMessageProvider
{
public string GetMessage() => "This is so exciting!";
}
// Register your provider in DI
services.AddSingleton<IMessageProvider, CustomExcitedProvider>();
services.AddSingleton<Dictionary<MoodType, IMessageProvider>>(provider =>
{
var dict = new Dictionary<MoodType, IMessageProvider>
{
[MoodType.Neutral] = new NeutralProvider(),
// ... other built-in providers
[MoodType.ErrorBased] = new ErrorBasedProvider(),
// Add your custom provider
[MoodType.Custom] = provider.GetRequiredService<CustomExcitedProvider>()
};
return dict;
});
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support & Contributing
We welcome issues, feature requests, and contributions! Please open an issue or submit a pull request on GitHub.
For questions or support, contact the maintainer via GitHub or open a discussion.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.