AwesomeChatBot 0.2.0-pre

This is a prerelease version of AwesomeChatBot.
There is a newer version of this package available.
See the version list below for details.
dotnet add package AwesomeChatBot --version 0.2.0-pre
NuGet\Install-Package AwesomeChatBot -Version 0.2.0-pre
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="AwesomeChatBot" Version="0.2.0-pre" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AwesomeChatBot --version 0.2.0-pre
#r "nuget: AwesomeChatBot, 0.2.0-pre"
#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 AwesomeChatBot as a Cake Addin
#addin nuget:?package=AwesomeChatBot&version=0.2.0-pre&prerelease

// Install AwesomeChatBot as a Cake Tool
#tool nuget:?package=AwesomeChatBot&version=0.2.0-pre&prerelease

AwesomeChatBot

AwesomeChatBot is a chat bot framework that can work with any chat program. It is built on .net core, and thus OS independent.

Extensebility<br /> The framework was built with extensibility in mind. Pretty much any part from this framework can be overriden and tailored to the personal needs. Basically everything is decoupled and talks through standardised interfaces to each other <br />


The set of classes / modules this framework provides by default, will give you a good start and should allow you to implement the common use cases.

Moduls<br /> This framework uses moduls to allow you to define, how your chat commands will be handled, how the bot reacts to them, basically how the user interacts with the bot.

Getting started

For starters and a quick reference, check my own bot https://github.com/RononDex/Astrobot on how the framework is implemented, it's pretty straight forward!

The most important parts for the chat bot developer are

  • ApiWrappers
  • CommandHandlers
  • Commands

Here some quick code to initialize the framework:

var discordWrapper = new DiscordWrapper(discordToken, loggerFactory);
var chatbotFramework = new AwesomeChatBot.AwesomeChatBot(discordWrapper, loggerFactory, chatbotSettings);

This code initializes the framework using the discord API wrapper. loggerFactory is the factory used to create loggers, this allows you to use your logging framework of choise (loggerFactory is of type ILoggerFactory from the Microsoft.Extensions.Logging nuget package). And last chatBotSettings is a value object passing on the different config values.

API Wrappers

Since the framework is decoupled from the chat app API, the framework won't be able to use any chat application by default. For each chat application one will need an API Wrapper doing the talking between your bot / the bot framework and the chat app API.

One API wrapper that was also written by me, is the AwesomeChatBot.Discord wrapper, <br/>see github here: https://github.com/RononDex/AwesomeChatBot.Discord <br/>or Nuget here: https://www.nuget.org/packages/AwesomeChatBot.Discord/

If a wrapper for yout chat app does not exist, you can create your own wrapper, it's pretty easy, but more on that later.

Command Handlers

Command handlers are a central part of the framework, they decided when and which command has to be executed. When a message gets passed down from the API wrapper to the framework, it will go though every registered CommandHandler, and check wether one of them says "yes, that message has to execute that command". Every handler has a function ShouldExecuteCommand that determines wether a chat message should trigger a given command.


Every command handler has a corresponding interface type, that a command has to implement in order to get triggered by that handler. For example the regex command handler has the interface IRegexCommand associated with it, which the command then can derive from.

As an example, see the RegexCommandHandler implementation here: https://github.com/RononDex/AwesomeChatBot/blob/master/AwesomeChatBot/Commands/Handlers/RegexCommandHandler.cs

Commands

And last but not least the commands. Every command represents an action or several actions that a user can trigger. To create a new command, simply create a new class, and derive it from AwesomeChatBot.Commands.Command (which will only add a "Name" property for the command) and also from every command handler type that you want the command to be triggered from. For example:

public class TestCommand : AwesomeChatBot.Commands.Command, IRegexCommand
{
    /// <summary>
    /// A list of regex patterns that trigger the command
    /// </summary>
    public List<string> Regex => new List<string>() { "test (?'TestParam'.*\\w)" };

    /// <summary>
    ///  Unique name of the command
    /// </summary>
    public override string Name => "Test";

    /// <summary>
    /// Execute the command
    /// </summary>
    /// <param name="recievedMessage"></param>
    /// <param name="regexMatch"></param>
    /// <returns></returns>
    public Task<bool> ExecuteRegexCommand(RecievedMessage recievedMessage, Match regexMatch) {
        return Task<bool>.Factory.StartNew(() => {

            var testParam = regexMatch.Groups["TestParam"].Value;

            recievedMessage.Channel.SendMessageAsync(new SendMessage($"IT'S WORKING!!! You entered {testParam}")).Wait();

            return true;
        });

    }
}

Registering Commands and Command Handlers

The commands and the command handlers need to be registered with the framework. These can be regsitered in the following way:

var chatbotFramework = new AwesomeChatBot.AwesomeChatBot(discordWrapper, loggerFactory, chatbotSettings);
chatbotFramework.RegisterCommand(new Commands.TestCommand());
chatbotFramework.RegisterCommandHandler(new AwesomeChatBot.Commands.Handlers.RegexCommandHandler());
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AwesomeChatBot:

Package Downloads
AwesomeChatBot.Discord

This package will allow your bot built with the AweomeChatBot framework to access discord. For further documentation see the project site.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.8.7 1,406 3/16/2022
1.8.6 1,013 8/8/2021
1.8.3 1,267 8/8/2021
1.8.2 1,055 7/8/2021
1.8.1 1,089 3/2/2021
1.8.0 1,057 2/28/2021
1.7.3 981 1/28/2021
1.7.1 1,201 9/25/2020
1.7.0 1,122 9/25/2020
1.6.4 1,029 9/24/2020
1.6.3 1,147 9/17/2020
1.6.2 1,039 9/17/2020
1.6.1 1,255 8/22/2020
1.6.0 1,294 2/24/2020
1.5.3 1,331 11/11/2019
1.5.2 1,143 9/6/2019
1.5.1 1,120 9/6/2019
1.5.0 1,496 8/31/2019
1.4.0 1,316 8/21/2019
1.3.2 1,208 6/11/2019
1.3.1 1,157 6/10/2019
1.3.0 1,516 6/10/2019
1.2.1 1,483 3/8/2019
1.2.0 1,357 3/5/2019
1.1.0 1,419 2/28/2019
1.0.2 1,888 1/23/2019
1.0.1 1,644 1/21/2019
1.0.0 1,420 1/21/2019
0.4.2-pre 1,256 1/21/2019
0.4.1-pre 2,027 1/21/2019
0.4.0-pre 2,160 1/19/2019
0.3.1-pre 2,282 1/4/2019
0.3.0-pre 1,364 11/16/2018
0.2.0-pre 1,261 10/19/2018
0.1.1-alpha 1,144 10/15/2018
0.1.0-alpha 1,285 10/14/2018

Initial upload for testing (WIP)