MoodyApi 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MoodyApi --version 1.0.0
                    
NuGet\Install-Package MoodyApi -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MoodyApi" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MoodyApi" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MoodyApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MoodyApi --version 1.0.0
                    
#r "nuget: MoodyApi, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MoodyApi@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MoodyApi&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MoodyApi&version=1.0.0
                    
Install as a Cake Tool

MoodyApi

NuGet License: MIT


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

  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 117 7/18/2025
1.0.1 148 7/17/2025
1.0.0 149 7/17/2025