Closed GeorgeSummers closed 5 months ago
Hey!
Yeah, ExGram have middlewares that executes before all the updates handlers, you can modify the updates, or all you want:
defmodule MyMiddleware do
use ExGram.Middleware
alias ExGram.Cnt
def call(%Cnt{update: update} = cnt, _opts) do
cnt
end
def call(cnt, _opts), do: cnt
end
An example that removes the bot's @username
from message text:
https://github.com/rockneurotiko/ex_gram/blob/master/lib/ex_gram/middleware/ignore_username.ex
I am writing a bot for a group and I want to collect some statistics from messages. Is there a way to do it without injecting new code in every handle/2 call? For example, I want to count some keywords from received messages per sender and then handle it, how can I do it without consuming the update data?