~ruther/NosSmooth.Local

ref: 06f078dcbeef77ec800477bc8057e5ac9bcde926 NosSmooth.Local/src/Extensions/NosSmooth.ChatCommands/ServiceCollectionExtensions.cs -rw-r--r-- 1.3 KiB
06f078dc — František Boháček chore: update dependencies 2 years ago
                                                                                
1
2
3
4
5
6
7
8
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
//
//  ServiceCollectionExtensions.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Extensions.DependencyInjection;
using NosSmooth.LocalClient;
using NosSmooth.LocalClient.Extensions;
using Remora.Commands.Extensions;

namespace NosSmooth.ChatCommands;

/// <summary>
/// Extension methods for <see cref="IServiceCollection"/>.
/// </summary>
public static class ServiceCollectionExtensions
{
    /// <summary>
    /// Adds NosTale commands and the interceptor to execute commands with.
    /// </summary>
    /// <param name="serviceCollection">The service collection.</param>
    /// <param name="prefix">The prefix for the commands.</param>
    /// <returns>The collection.</returns>
    public static IServiceCollection AddNostaleChatCommands(this IServiceCollection serviceCollection, string prefix = "#")
    {
        serviceCollection
            .Configure<ChatCommandsOptions>((o) => o.Prefix = prefix);

        return serviceCollection
            .AddCommands()
            .Configure<LocalClientOptions>(o => o.AllowIntercept = true)
            .AddSingleton<FeedbackService>()
            .AddPacketInterceptor<ChatCommandInterceptor>();
    }
}
Do not follow this link