API v2

CL-TELEGRAM-BOT2/ACTION

Classes

ACTION

Functions

function
obj func &rest args

Useful in cl-telegram-bot2/generics:process handlers in case if state has additional handler stored in the slot and this slot can be either state or action.

This function is recursive, because processing of an action could return another action and we should call FUNC until a new state or NIL will be returned.

CL-TELEGRAM-BOT2/ACTIONS/EDIT-MESSAGE-MEDIA

Classes

EDIT-MESSAGE-MEDIA

Readers

reader
(:caption)
reader
(:inline-keyboard)

Functions

function
path-or-func-name &key caption inline-keyboard

CL-TELEGRAM-BOT2/ACTIONS/SEND-INVOICE

Classes

SEND-INVOICE

Readers

reader
(:commands = nil)
reader
(:currency)
reader
(:description)
reader
(:on-success)
reader
(:payload)
reader
(:prices)
reader
(:provider-token)
reader
(:title)

Functions

function
title description payload provider-token currency prices &key on-success commands

Types

Type of prices arguments for send-invoice class.

(SOFT-LIST-OF HASH-TABLE)

CL-TELEGRAM-BOT2/ACTIONS/SEND-PHOTO

Classes

SEND-PHOTO

Readers

reader
(:caption)
reader
(:inline-keyboard)

Functions

function
path-or-func-name &key caption inline-keyboard

CL-TELEGRAM-BOT2/ACTIONS/SEND-TEXT

Classes

SEND-TEXT

Readers

reader
(:parse-mode = nil)

Supported values are: "Markdown", "MarkdownV2" or "HTML". Read more about formatting options in the Telegram documentaion: https://core.telegram.org/bots/api#formatting-options

reader
(:reply-markup = nil)
reader
(:text)

Functions

function
text-or-func-name &key reply-markup parse-mode

CL-TELEGRAM-BOT2/BOT

Macros

macro
name base-classes &optional slots &rest options

Use this macro to define a class of your Telegram bot.

Each bot has a state machine inside. The simplest bot has only one state:

(defbot test-bot ()
  ()
  (:initial-state
   (state (send-text "Hello world!"))))

This bot will green each who activates it.

To learn more about bot states and actions see States and Actions section.

CL-TELEGRAM-BOT2/ERRORS

Classes

TELEGRAM-ERROR

Readers

reader
(:DESCRIPTION = '(REQUIRED-ARGUMENT "DESCRIPTION is required argument for TELEGRAM-ERROR class."))

CL-TELEGRAM-BOT2/GENERICS

Generics

Pre-checkout-query object will be passed as this single arguement and function should return a boolean. When the function return True, user may proceed to the payment.

Pre-checkout queries are not bound the the chat, so current-chat and current-state are not available during processing. This is why methods of this generic function should be defined on bot class.

You can use CL-TELEGRAM-BOT2/API:PRE-CHECKOUT-QUERY-INVOICE-PAYLOAD function to extract payload from the query and find associated invoice.

This method is called when some state exits and returns a result using cl-telegram-bot2/term/back:back function.

This method is called when chat actor's state is changed to a given STATE.

Such hook can be used to send some prompt to the user.

This method is called when chat actor's state is returned from a given STATE back to the previous state.

The method is called only when state is removed from the stack. When a new state is added to the stack, this method will not be called for a previous state.

Such hook can be used to hide a keyboard or to delete temporary messages.

generic-function
bot-or-state object

This method is called by when processing a single update. It is called multiple times on different parts of an update. Whole pipeline looks like that:

For each update we call: process(bot, update) process(actor-state, update)

CL-TELEGRAM-BOT2/HIGH

High level API for implementing Telegram bots.

Classes

CHAT-STATE

Functions

function
text &rest rest &key business-connection-id message-thread-id parse-mode entities link-preview-options disable-notification protect-content allow-paid-broadcast message-effect-id reply-parameters reply-markup
function
photo &rest rest &key business-connection-id message-thread-id caption parse-mode caption-entities show-caption-above-media has-spoiler disable-notification protect-content allow-paid-broadcast message-effect-id reply-parameters reply-markup

Macros

Returns as the first value a list of messages created by reply function called during BODY execution. Values returned by the BODY code are returned as the second, third and following arguments.

Also, messages are collected when these actions are called:

  • cl-telegram-bot2/actions/send-text:send-text (1 2)

  • cl-telegram-bot2/actions/send-photo:send-photo (1 2)

CL-TELEGRAM-BOT2/SERVER

Functions

function
BOT &KEY DEBUG (DELAY-BETWEEN-RETRIES 10) (THREAD-NAME "telegram-bot")

Start processing new updates from the Telegram API.

Pass bot instance as the first argument and maybe some other optional arguments.

If DEBUG argument is T, then bot will ignore updates which it can't to process without errors. Otherwise, an interactive debugger will popup.

CL-TELEGRAM-BOT2/SPEC

Classes

TELEGRAM-OBJECT

CL-TELEGRAM-BOT2/STATE

Classes

STATE

Readers

reader
(:on-activation = nil)
reader
(:on-callback-query = nil)
reader
(:on-result = nil)
reader
(:on-update = nil)
reader
(:on-web-app-data = nil)

Functions

function
on-activation &key id commands on-update on-result on-callback-query on-web-app-data

Types

Type of ON-CALLBACK-QUERY argument of the state class.

(SERAPEUM:SOFT-ALIST-OF STRING (OR WORKFLOW-BLOCK WORKFLOW-BLOCKS))

CL-TELEGRAM-BOT2/STATE-WITH-COMMANDS

Classes

COMMAND

This type of command is available only in the state where it is defined.

GLOBAL-COMMAND

This command will be available during in all bot states.

STATE-WITH-COMMANDS-MIXIN

Readers

reader
(:commands = nil)

Functions

function
name handler &key description
function
name handler &key description

CL-TELEGRAM-BOT2/STATES/BASE

Classes

BASE-STATE

Readers

reader
(:id = nil)

Accessors

Generics

Functions

function
var-name

CL-TELEGRAM-BOT2/STATES/WAIT-FOR-PAYMENT

Classes

WAIT-FOR-PAYMENT

Readers

reader
(:on-success = nil)

Functions

function
&key on-success commands

CL-TELEGRAM-BOT2/TERM/BACK

Classes

BACK-TO-ID

Readers

reader
(:ID = (REQUIRED-ARGUMENT "Parent id is required argument."))

BACK-TO-NTH-PARENT

Readers

reader
(:N = (REQUIRED-ARGUMENT "Parent number required argument."))

BACK-TO

Readers

reader
(:STATE-CLASS = (REQUIRED-ARGUMENT "State class is required argument."))

BACK

Readers

reader
(:result = nil)

Functions

function
&optional result
function
state-class &optional result
function
id &optional result
function
n &optional result

CL-TELEGRAM-BOT2/TYPES

Types

(OR CL-TELEGRAM-BOT2/API:REPLY-KEYBOARD-MARKUP
    CL-TELEGRAM-BOT2/API:REPLY-KEYBOARD-REMOVE
    CL-TELEGRAM-BOT2/API:INLINE-KEYBOARD-MARKUP
    CL-TELEGRAM-BOT2/API:FORCE-REPLY)

CL-TELEGRAM-BOT2/UTILS

Generics

Does a general deep-copy on the given object and sub-pieces. Returns atoms, numbers and chars. Runs copy-tree on lists, and copy-seq on other sequences. Runs copy-structure on pathnames, hash tables and other structure-objects

Functions

function
funcallable
function
value &rest args

If value is a fbound SYMBOL, then calls as a function and then returns a result.

CL-TELEGRAM-BOT2/WORKFLOW

Types

(AND SYMBOL (SATISFIES FBOUNDP))
(OR FUNCALLABLE-SYMBOL BASE-STATE ACTION BACK)
(SOFT-LIST-OF WORKFLOW-BLOCK)