Giter Site home page Giter Site logo

excalib88 / botf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deploy-f/botf

1.0 0.0 0.0 179 KB

🦾Make beautiful and clear telegram bots with the asp.net-like architecture!

Home Page: https://deploy-f.com

License: MIT License

C# 99.05% PowerShell 0.95%

botf's Introduction

BotF

Nuget GitHub CI

Make beautiful and clear telegram bots with the asp.net-like architecture!

BotF have next features:

  • long pooling and webhook mode without any changes in the code
  • very convinient way to work with commands and reply buttons
  • integrated pagination with buttons
  • authentication and role-based authorization
  • statemachine for complicated dialogs with users
  • asp.net-like approach to develop bots
  • automatic creating of command menu
  • integrated DateTime picker
  • auto sending
  • good performance

Documentaion

Visit to our wiki to read botf documentation

Install

dotnet add package Deployf.Botf

Example

Put next code into Program.cs file

using Deployf.Botf;

class Program : BotfProgram
{
    // It's boilerplate program entrypoint.
    // We just simplified all usual code into static method StartBot.
    // But in this case of starting of the bot, you should add a config section under "bot" key to appsettings.json
    public static void Main(string[] args) => StartBot(args);

    // Action attribute mean that you mark async method `Start`
    // as handler for user's text in message which equal to '/start' string.
    // You can name method as you want
    // And also, second argument of Action's attribute is a description for telegram's menu for this action
    [Action("/start", "start the bot")]
    public void Start()
    {
        // Just sending a reply message to user. Very simple, isn't?
        Push($"Send `{nameof(Hello)}` to me, please!");
    }

    [Action(nameof(Hello))]
    public void Hello()
    {
        Push("Hey! Thank you! That's it.");
    }

    // Here we handle all unknown command or just text sent from user
    [On(Handle.Unknown)]
    public async Task Unknown()
    {
        // Here, we use the so-called "buffering of sending message"
        // It means you dont need to construct all message in the string and send it once
        // You can use Push to just add the text to result message, or PushL - the same but with new line after the string.
        PushL("You know.. it's very hard to recognize your command!");
        PushL("Please, write a correct text. Or use /start command");

        // And finally, send buffered message
        await Send();
    }
}

And replace content of appsettings.json with your bot username and token:

{
  "bot": {
    "Token": "123456778990:YourToken",
    "Username": "username_bot",
    "AutoSend": true
  }
}

And that's it! Veeery easy, isn't?
Just run the program :)

Other examples you can find in /Examples folder.

Hosting

After you develop your bot, you can deploy it to our hosting: deploy-f.com

botf's People

Contributors

k0dep avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.