struct Telecr::Core::Handler

Overview

Handler struct - stores user's code and when to run it

Defined in:

core/handler.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(filters : Hash(String, Bool | Int32 | Int64 | Regex | String | Nil), proc : Telecr::Core::Context -> _) #

[View source]

Instance Method Detail

def call(ctx : Context) #

Execute the handler with given context


[View source]
def call_count : Int32 #

How many times this handler has been called (useful for stats)


[View source]
def call_count=(call_count : Int32) #

How many times this handler has been called (useful for stats)


[View source]
def created_at : Time #

Time this handler was registered


[View source]
def filters : Hash(String, FilterValue) #

Filters determine when this handler should run


[View source]
def handle_dynamic_filter(ctx : Context, key : String, value : FilterValue) : Bool #

Handle dynamic filter keys without using responds_to? with dynamic symbols


[View source]
def matches?(ctx : Context) : Bool #

Check if this handler should run for the given context


[View source]
def matches_chat_type?(ctx, type : FilterValue) : Bool #

[View source]
def matches_command?(ctx, cmd_name : FilterValue) : Bool #

[View source]
def matches_text?(ctx, pattern : FilterValue) : Bool #

[View source]
def proc : Context -> #

The actual user code that runs


[View source]
def to_s(io : IO) : Nil #

String representation for debugging


[View source]