Search Results for

    Show / Hide Table of Contents

    Actions

    Common text messages
    Can be combined with Keyboards

    Adding action

    Create in your Telegram Module public method with ActionAttribute

    using TelegramModularFramework.Modules;
    
    public class SampleModule: TelegramModule
    {
        [Action]
        public async Task ShowSomething()
        {
            await ReplyAsync($"Welcome!");
        }
    }
    

    By default action name generates from method name ActionName -> Action Name
    You can specify name by passing name argument to ActionAttribute
    Name cannot contain spaces

    [Action("Test")]
    

    Arguments

    Cannot retrive arguments but as other handlers can activate @Guides.Handlers.State to get some information

    Run Mode

    Run mode can be specified with RunModeAttribute
    Sync - Default. Commands executes in order
    Async - Commands executes asynchronously

    Summary

    To add summary to command use SummaryAttribute

    [Summary("Do things")]
    

    On Action Executed

    Subscribe to ActionExecuted event to handle action post execution

    Exceptions

    If action executed unsuccesfully handle Exception
    Possible exception:

    • UnknownCommand
    • BaseCommandException
    • @System.Exception
    • Improve this Doc
    ☀
    ☾
    In This Article
    Back to top
    TelegramModularFramework (c) 2022-2022
    ☀
    ☾