Sexy.Bot.Poller (Sexy v0.9.13)

Copy Markdown View Source

GenServer that polls Telegram for updates and routes them to Sexy.Bot.Session callbacks.

Started automatically as a child of Sexy.Bot. Each incoming update is dispatched in a separate Task to avoid blocking the polling loop.

Routing rules

Update typeConditionSession callback
messagetext starts with /handle_command/1
messageotherwisehandle_message/1
callback_querydata starts with /_deletebuilt-in: deletes the message
callback_querydata starts with /_transitbuilt-in: deletes + handle_transit/3
callback_queryotherwisehandle_query/1
messagehas successful_paymenthandle_successful_payment/1
pre_checkout_queryhandle_pre_checkout/1
pollhandle_poll/1
my_chat_memberhandle_chat_member/1

Built-in routes

  • /_delete mid=<id> — deletes message with given id, answers the callback
  • /_transit mid=<id>-cmd=<command>-... — deletes message, answers callback, then calls Session.handle_transit(chat_id, command, query_params)

Summary

Functions

apply_chat_member(u)

apply_command(u)

apply_message(u)

apply_poll(u)

apply_pre_checkout(u)

apply_query(u)

apply_successful_payment(u)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(atom)

Callback implementation for GenServer.init/1.

start_link(g)

update()