TDW.Marv.Core
0.9.1
dotnet add package TDW.Marv.Core --version 0.9.1
NuGet\Install-Package TDW.Marv.Core -Version 0.9.1
<PackageReference Include="TDW.Marv.Core" Version="0.9.1" />
<PackageVersion Include="TDW.Marv.Core" Version="0.9.1" />
<PackageReference Include="TDW.Marv.Core" />
paket add TDW.Marv.Core --version 0.9.1
#r "nuget: TDW.Marv.Core, 0.9.1"
#:package TDW.Marv.Core@0.9.1
#addin nuget:?package=TDW.Marv.Core&version=0.9.1
#tool nuget:?package=TDW.Marv.Core&version=0.9.1
TDW.Marv.Core
Core library for the Marv IRC bot. Provides the plugin API, bot abstractions, IRC protocol handling, and service registry.
Who is this for?
This package is for plugin authors building extensions for Marv. It provides the base classes, attributes, context types, and interfaces you need to write plugins.
If you're writing tests for your plugins, also add TDW.Marv.Testing.
Quick start
Create a class library targeting the same .NET version as Marv, add a reference to this package, and implement a plugin:
using Marv.Core.Platform;
using Marv.Core.Plugin;
using Microsoft.Extensions.Logging;
public class HelloPlugin : MarvPlugin
{
public HelloPlugin(IBot bot, IPluginActivator activator, ILoggerFactory loggerFactory)
: base(bot, activator, loggerFactory) { }
[OnCommand("hello")]
private async Task HandleHello(CommandContext ctx, CancellationToken ct)
{
await ctx.ReplyAsync($"Hi, {ctx.Sender.Nick}!", ct);
}
}
Key types
| Type | Description |
|---|---|
MarvPlugin |
Base class for all plugins |
IBot |
Bot instance — send messages, query state |
CommandContext |
Context for [OnCommand] handlers |
RegexMatchContext |
Context for [OnRegex] handlers |
IPluginActivator |
Create instances with DI resolution |
IFilteringAttribute |
Declare handler filter attributes |
FilterEvaluator<T> |
Implement handler filter logic |
Handler attributes
| Attribute | Handler signature | Fires when |
|---|---|---|
[OnCommand("name")] |
Task(CommandContext, CancellationToken) |
Prefixed command message |
[OnRegex("pattern")] |
Task(RegexMatchContext, CancellationToken) |
Message matches pattern |
[OnEvent] |
Task(TEvent, CancellationToken) |
Typed event (inferred from parameter) |
[OnRawMessage("CMD")] |
Task(IrcMessage, CancellationToken) |
Raw IRC message |
[OnInterval(Seconds = n)] |
Task(CancellationToken) |
Timer tick while connected |
All handler methods may omit the CancellationToken parameter.
Configuration
Declare a config class with [PluginConfig] and inject IOptions<T>:
[PluginConfig(Section = "MyPlugin")]
public record MyConfig
{
public string Greeting { get; init; } = "Hello!";
}
Config binds to a root-level JSON section matching the Section name.
IOptionsMonitor<T> is also available for live-reload support.
Services
Plugins can provide services to other plugins via [ProvidesService] and
ConfigureServices. Consume services by adding constructor parameters
(use = null for optional dependencies).
Documentation
Full API reference: Plugin API docs
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Console (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- System.Reflection.MetadataLoadContext (>= 10.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TDW.Marv.Core:
| Package | Downloads |
|---|---|
|
TDW.Marv.Testing
Test helpers for Marv IRC bot plugins. Provides builders for CommandContext, RegexMatchContext, events, and a plugin test harness. |
GitHub repositories
This package is not used by any popular GitHub repositories.