Search Results for

    Show / Hide Table of Contents

    Class TelegramModulesService

    Service for handling commands, actions and states from registered modules

    Inheritance
    System.Object
    TelegramModulesService
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: TelegramModularFramework.Services
    Assembly: TelegramModularFramework.dll
    Syntax
    public class TelegramModulesService

    Constructors

    | Improve this Doc View Source

    TelegramModulesService(IServiceProvider, ILogger<TelegramModulesService>, TelegramBotUser, IStringSplitter, ITelegramBotClient, IOptions<TelegramModulesConfiguration>, IStateHolder, ICultureInfoUpdater)

    Declaration
    public TelegramModulesService(IServiceProvider provider, ILogger<TelegramModulesService> logger, TelegramBotUser telegramBotUser, IStringSplitter splitter, ITelegramBotClient client, IOptions<TelegramModulesConfiguration> config, IStateHolder stateHolder, ICultureInfoUpdater cultureInfoUpdater)
    Parameters
    Type Name Description
    IServiceProvider provider
    Microsoft.Extensions.Logging.ILogger<TelegramModulesService> logger
    TelegramBotUser telegramBotUser
    IStringSplitter splitter
    Telegram.Bot.ITelegramBotClient client
    Microsoft.Extensions.Options.IOptions<TelegramModulesConfiguration> config
    IStateHolder stateHolder
    ICultureInfoUpdater cultureInfoUpdater

    Properties

    | Improve this Doc View Source

    Commands

    List of all commands

    Declaration
    public Dictionary<string, CommandInfo> Commands { get; }
    Property Value
    Type Description
    Dictionary<System.String, CommandInfo>
    | Improve this Doc View Source

    Modules

    List of all loaded modules

    Declaration
    public List<ModuleInfo> Modules { get; }
    Property Value
    Type Description
    List<ModuleInfo>
    | Improve this Doc View Source

    VisibleCommands

    List of all visible commands

    Declaration
    public IEnumerable<CommandInfo> VisibleCommands { get; }
    Property Value
    Type Description
    IEnumerable<CommandInfo>

    Methods

    | Improve this Doc View Source

    AddModule(Type)

    Adds single module

    Declaration
    public void AddModule(Type module)
    Parameters
    Type Name Description
    Type module

    Type of class inherited from TelegramModule

    | Improve this Doc View Source

    AddModule<T>()

    Adds single module

    Declaration
    public void AddModule<T>()
        where T : TelegramModule
    Type Parameters
    Name Description
    T

    Class inherited from TelegramModule

    | Improve this Doc View Source

    AddModules(Assembly)

    Adds all modules from given assembly. If assembly is null, the calling assembly is taken.

    Declaration
    public void AddModules(Assembly assembly = null)
    Parameters
    Type Name Description
    System.Reflection.Assembly assembly

    Assembly to get modules.

    | Improve this Doc View Source

    ChangeStateAsync(Int64, String)

    Changes state of user by chatId and path

    Declaration
    public async Task ChangeStateAsync(long chatId, string path)
    Parameters
    Type Name Description
    System.Int64 chatId

    Chat Id

    System.String path

    Relative or absolute path

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    HandleUpdateAsync(ITelegramBotClient, Update, CancellationToken)

    Handle update from telegram bot api and executes modules

    Declaration
    public async Task<bool> HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Telegram.Bot.ITelegramBotClient botClient

    BotClient from update event

    Telegram.Bot.Types.Update update

    Update object from update event

    CancellationToken cancellationToken

    CancellationToken from update event

    Returns
    Type Description
    Task<System.Boolean>

    true if update handled by framework otherwise returns false

    | Improve this Doc View Source

    InvokeCallbackHandler(CallbackQueryHandlerInfo, TelegramModule, String, IServiceProvider)

    Declaration
    public async Task InvokeCallbackHandler(CallbackQueryHandlerInfo callbackQueryHandlerInfo, TelegramModule module, string data, IServiceProvider scoped)
    Parameters
    Type Name Description
    CallbackQueryHandlerInfo callbackQueryHandlerInfo
    TelegramModule module
    System.String data
    IServiceProvider scoped
    Returns
    Type Description
    Task
    | Improve this Doc View Source

    SetMyCommands()

    Sets list of commands via telegram bot api See Telegram.Bot.TelegramBotClientExtensions.SetMyCommandsAsync(Telegram.Bot.ITelegramBotClient,System.Collections.Generic.IEnumerable{Telegram.Bot.Types.BotCommand},Telegram.Bot.Types.BotCommandScope,System.String,System.Threading.CancellationToken) for details

    Declaration
    public async Task SetMyCommands()
    Returns
    Type Description
    Task
    | Improve this Doc View Source

    UrlFor(Type, Object)

    Declaration
    public string UrlFor(Type type, object parameters = null)
    Parameters
    Type Name Description
    Type type
    System.Object parameters
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    UrlFor(Type, String, Object)

    Declaration
    public string UrlFor(Type type, string handler, object parameters = null)
    Parameters
    Type Name Description
    Type type
    System.String handler
    System.Object parameters
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    UrlFor<TModule>(Object)

    Declaration
    public string UrlFor<TModule>(object parameters = null)
        where TModule : TelegramModule
    Parameters
    Type Name Description
    System.Object parameters
    Returns
    Type Description
    System.String
    Type Parameters
    Name Description
    TModule
    | Improve this Doc View Source

    UrlFor<TModule>(String, Object)

    Declaration
    public string UrlFor<TModule>(string handler, object parameters = null)
        where TModule : TelegramModule
    Parameters
    Type Name Description
    System.String handler
    System.Object parameters
    Returns
    Type Description
    System.String
    Type Parameters
    Name Description
    TModule

    Events

    | Improve this Doc View Source

    ActionExecuted

    Async event that executes after action executed successfully or not

    Declaration
    public event Func<ActionInfo, ModuleContext, Result, Task>? ActionExecuted
    Event Type
    Type Description
    System.Nullable<Func<ActionInfo, ModuleContext, Result, Task>>
    | Improve this Doc View Source

    CallbackExecuted

    Async event that executes after state executed successfully or not

    Declaration
    public event Func<CallbackQueryHandlerInfo, ModuleContext, Result, Task>? CallbackExecuted
    Event Type
    Type Description
    System.Nullable<Func<CallbackQueryHandlerInfo, ModuleContext, Result, Task>>
    | Improve this Doc View Source

    CommandExecuted

    Async event that executes after command executed successfully or not

    Declaration
    public event Func<CommandInfo, ModuleContext, Result, Task>? CommandExecuted
    Event Type
    Type Description
    System.Nullable<Func<CommandInfo, ModuleContext, Result, Task>>
    | Improve this Doc View Source

    StateExecuted

    Async event that executes after state executed successfully or not

    Declaration
    public event Func<StateInfo, ModuleContext, Result, Task>? StateExecuted
    Event Type
    Type Description
    System.Nullable<Func<StateInfo, ModuleContext, Result, Task>>
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top
    TelegramModularFramework (c) 2022-2022
    ☀
    ☾