Navigator 1.9.3-beta1

This is a prerelease version of Navigator.
dotnet add package Navigator --version 1.9.3-beta1
NuGet\Install-Package Navigator -Version 1.9.3-beta1
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="Navigator" Version="1.9.3-beta1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Navigator --version 1.9.3-beta1
#r "nuget: Navigator, 1.9.3-beta1"
#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.
// Install Navigator as a Cake Addin
#addin nuget:?package=Navigator&version=1.9.3-beta1&prerelease

// Install Navigator as a Cake Tool
#tool nuget:?package=Navigator&version=1.9.3-beta1&prerelease

A highly opinionated telegram bot framework, mainly based on Telegram.Bot.

This framework relies heavily in MediatR and it is shaped accordingly.

The base package (Navigator) it's usable on it's own but the Actions extension it's highly encouraged as it brings default implementations for almost every type of incoming telegram update, in the future we may merge it into the base package.

For storage of users, chats and conversations the Store extension works really well with Navigator, it automatically recognizes users and groups, saves them to the database for future use and injects into the NavigatorContext all the data you may have about a user or a chat, you can also use your own models and it will still work, check out the examples for more information.

Finally the Shipyard WIP package gives you an useful API to retrieve information about your bot, change some of it's configuration and launch some actions. A companion web-based UI is also planned.

Packages

Package Last Stable Last Prerelease
Navigator package.nav package.nav.pre
Navigator.Extensions.Actions package.nav.ext.act package.nav.ext.act.pre
Navigator.Extensions.Store package.nav.ext.sto package.nav.ext.sto.pre
Navigator.Extensions.Shipyard package.nav.ext.ship package.nav.ext.ship.pre

Requirements

  • ASP.NET (>= net5.0)
  • MediatR (>= 9.0.0)

Examples

Some examples can be found in the samples repository.

Also checkout some bots made with Navigator:

Basic Usage

Configuration

Including Navigator in your project is simple:

public class Startup
{
    // ...

    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.AddControllers().AddNewtonsoftJson();

        services.AddMediatR(typeof(Startup).Assembly); // And any other assembly that may be needed.
        
        services.AddNavigator(options =>
        {
            options.SetTelegramToken(Configuration["BOT_TOKEN"]); // Your telegram bot token.
            options.SetWebHookBaseUrl(Configuration["BASE_WEBHOOK_URL"]); // The base url where you are going to receive the updates from teelgram.
            options.RegisterActionsFromAssemblies(typeof(Startup).Assembly); // All your actions.
        });

        /// ...
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            /// ...

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapNavigator(); // In order to receive updates from telegram.
            });

            /// ...
        }
}

More options are available, check out the wiki.

Bot Actions

Example of a basic echo action using the base package + the actions extension.

public class EchoAction : MessageAction
{
    public string MessageToEcho { get; set; } = string.Empty;
    
    public override IAction Init(INavigatorContext ctx)
    {
        if (string.IsNullOrWhiteSpace(ctx.Update.Message.Text))
        {
            MessageToEcho = ctx.Update.Message.Text;
        }
        return this;
    }

    public override bool CanHandle(INavigatorContext ctx)
    {
        return !string.IsNullOrWhiteSpace(MessageToEcho);
    }
}

/// ...

public class EchoActionHandler : ActionHandler<EchoAction>
{
    public EchoActionHandler(INavigatorContext ctx) : base(ctx)
    {
    }

    public override async Task<Unit> Handle(EchoAction request, CancellationToken cancellationToken)
    {
        await Ctx.Client.SendTextMessageAsync(Ctx.GetTelegramChat(), request.MessageToEcho,
            cancellationToken: cancellationToken);

        return Unit.Value;
    }
}

License

Navigator Framework Copyright (C) 2019-2021 Lucas Maximiliano Marino

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

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

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Navigator:

Package Downloads
Navigator.Extensions.Store

Persistence extension for Navigator Framework bots, requires provider implementations.

Navigator.Extensions.Cooldown

Specify the cooldown for an action to be triggered again with ease

Navigator.Extensions.Interop

Extend your navigator bot with python scripts interop.

Navigator.Providers.Telegram

Telegram provider for Navigator Framework. Implementation based on Telegram.Bot

Navigator.Extensions.Probabilities

Specify the probabilities of an action being triggered with ease.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.9.3-beta1 778 4/9/2022
1.9.2-beta1 634 4/7/2022
1.9.1-beta3 387 4/7/2022
1.9.1-beta2 157 4/6/2022
1.9.1-beta1 289 4/5/2022
1.9.0-beta9 130 4/5/2022
1.9.0-beta8 142 4/5/2022
1.9.0-beta7 133 4/5/2022
1.9.0-beta6 143 4/5/2022
1.9.0-beta4 132 4/5/2022
1.9.0-beta2 136 4/4/2022
1.9.0-beta10 136 4/5/2022
1.9.0-beta1 129 4/4/2022