cl-telegram-bot
2025-06-22
Telegram Bot API, based on sovietspaceship's work but mostly rewritten.
Upstream URL
Author
License
cl-telegram-bot - Telegram Bot API
CL-TELEGRAM-BOT ASDF System Details
- Description: Telegram Bot
API
, based on sovietspaceship's work but mostly rewritten. - Licence:
MIT
- Author: Alexander Artemenko svetlyak.40wt@gmail.com
- Homepage: https://40ants.com/cl-telegram-bot/
- Bug tracker: https://github.com/40ants/cl-telegram-bot/issues
- Source control: GIT
- Depends on: alexandria, anaphora, arrows, bordeaux-threads, cl-ppcre, cl-strings, closer-mop, dexador, jonathan, kebab, log4cl, serapeum, str, trivial-backtrace, yason
Installation
You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload :cl-telegram-bot)
v2
States and Actions
This framework makes it possible to define bot with all allowed state.
The state defines behaviour of the bot, the way it should respond to commands, updates and other events.
States
There can be more than one handler for the event. We call these handlers "Actions".
An action should return a NIL
or a new state. In latter case, the current bot's state will be changed to the new one and handlers for on-activation
event will be called.
State is constructed using state
function, which accepts handlers for different kinds of events. Here is simples state which greets a user when it start the chat and then reply with the same text:
(defun reply-with-same-text (update)
(reply (message-text
(update-message update)))
(values))
(state (send-text "Hello, I'm the echo bot.")
:on-update 'reply-with-same-text)
The first argument to state
function is a handler for on-activation
event. If you don't want to react on activation, you can pass NIL
instead. The send-text
function returns an action instance. This way, we tell what bot should do, we use a declarative way to describe bot's behaviour.
The :ON-UPDATE
argument specifies a handler for on-update
event. This is the most generic event which occur when bot receives an update which wasn't processed by other event handlers. For this handler we are using a custom function bound to the symbol reply-with-same-text
. The function accepts a single argument - update object. Use generic functions from cl-telegram-bot2/api
package to work with this update object.
The reason why we only accept a special action object or a symbol but not a lambda function is because this way we'll be able to generate schemas of all states and transitions between them. Another reason is that it will be possible to redefine fbound function and use interactive approach to changing bot's behaviour.
See other support events in state
function documentation.
Actions
Actions in cl-telegra-bot are small objects holding an information about what should be done on some event. Typically, you will want to reply with some text or send a photo.
Usually, actions are created using a function having the same name as action's class. Here are which actions are available:
More actions will be added in future and you can create your own.
Also, a function bound symbol can be used instead an action object. Why do we require a symbol but not a function object? Because symbol has a name and it can be useful when we want to save bot's state or to render states graph.
Event processing
When some event occur, a corresponding generic function is called first on state object then on an action specified for this kind.
For example, if new update was received, then cl-telegram-bot2/generics:process
generic-function will be called with current state as the first argument
and update object as the second argument. Then the method specified on state class will call the same cl-telegram-bot2/generics:process
generic-function
on the object specified as :ON-UPDATE
argument for the action. If action is a symbol, then it's function will be called with update object as a single argument in case if this function accepts one argument and without any arguments otherwise.
Action's method should return should return a new state object if it wants to change the current bot's state or NIL
otherwise. If new state was returned, then on-activate
event will be processed afterwards.
Instead of one action a list of actions can be specified as an event handler. In this case processing will stop on an action which returns a new state.
Our Telegram First Bot (tutorial)
For the start, you need to create a bot and get it's token from the BotFather bot:
When you've got token, go to the REPL
and define our bot:
CL-USER> (defvar *token* "52...")
CL-USER> (cl-telegram-bot2/bot:defbot test-bot ()
())
CL-USER> (cl-telegram-bot2/server:start-polling (make-test-bot *token*))
Last call will be interrupted with Required argument "Initial state is required argument." missing.
error.
This is because in second version of cl-telegram-bot bot always should have some state. From the current state
depends bot's behaviour, commands which are available and a set of handlers for different events. Each chat
has it's own current state. This allows bot to keep context when working with each user.
When you are creating a bot instance, you should give at a state definition. Let's create a bot with simple state which will great a new user:
CL-USER> (cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!"))))
#<FUNCTION (FLET CL-TELEGRAM-BOT2/SERVER::STOP-BOT :IN CL-TELEGRAM-BOT2/SERVER:START-POLLING) {100B11524B}>
CL-USER> (defparameter *stop-func* *)
Note, the bot was started and a function which can stop it was returned from cl-telegram-bot2/server:start-polling
function.
Now let's see how our bot will behave:
As you can see, our bot greets the user but does not respond ot it's message. What if we'll use send-text
function to create
an action for update event?
CL-USER> (funcall *stop-func*)
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
:on-update (cl-telegram-bot2/actions/send-text:send-text
"The response to the message")))))
Now our bot will respond to the message with a static message:
Good! But what if we want to execute some custom logic before reponse? The one way is to define your own action class, but the easiest way is to use a function. For demonstration, we'll create a function which will reply with a reversed text:
CL-USER> (funcall *stop-func*)
CL-USER> (defun reply-with-reversed-text (update)
(cl-telegram-bot2/high:reply
(reverse (cl-telegram-bot2/api:message-text
(cl-telegram-bot2/api:update-message update))))
;; Return no values because we don't want to change
;; the state:
(values))
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
;; Note, here we specify as a handler the fbound symbol:
:on-update 'reply-with-reversed-text))))
Now let's combine two actions together. First we'll send a static text, then call a function and send the reversed user input:
CL-USER> (funcall *stop-func*)
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
;; Note, here we specify as a handler the list of an action
;; and a fbound symbol:
:on-update (list (cl-telegram-bot2/actions/send-text:send-text
"Here how you text will look like when reversed:")
'reply-with-reversed-text)))))
As we said in the beginning of the tutorial, the real power of the second version of cl-telegram-bot is it's ability to keep context as the current state. At the next step we'll create the second state at which bot will calculate the number of symbols in the user input.
Here is how the workflow will work:
- On /start command the bot will switch to the first state and greet the user.
- On any message, the bot will repond with it's reversed version and then switch to the second state.
- In the second state the bot will respond with a number of symbols in user's input.
CL-USER> (defun reply-with-num-symbols (update)
(let ((input-text
(cl-telegram-bot2/api:message-text
(cl-telegram-bot2/api:update-message update))))
(cl-telegram-bot2/high:reply
(format nil "Your input has ~A chars."
(length input-text)))
;; Return no values because we don't want to change
;; the state:
(values)))
CL-USER> (funcall *stop-func*)
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
;; Note, here we specify as a handler the list of an action
;; and a fbound symbol:
:on-update (list (cl-telegram-bot2/actions/send-text:send-text
"Here how you text will look like when reversed:")
'reply-with-reversed-text
;; Now switch to the second state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Now bot is in the second state.")
;; This is how we count the symbols in user input
:on-update 'reply-with-num-symbols))))))
As you can see, now our bot has stuck in the second state and there is no way to jump back to the first one. How would we do this?
State change inside the bot creates a stack of states:
- Second state (current)
- First state
There are special actions which allows to unwind this stack to one of the previous states:
cl-telegram-bot2/term/back:back
- goes the previous state.cl-telegram-bot2/term/back:back-to
- goes the previous state or given class.cl-telegram-bot2/term/back:back-to-nth-parent
- just likecl-telegram-bot2/term/back:back
, but allows to jump a few levels higher.cl-telegram-bot2/term/back:back-to-id
- allows to go to the state with a given id (id is an optional state attribute and especially useful for returning to the particular state).
Let's try to use the simplest form to return to the first state:
CL-USER> (funcall *stop-func*)
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
;; Note, here we specify as a handler the list of an action
;; and a fbound symbol:
:on-update (list (cl-telegram-bot2/actions/send-text:send-text
"Here how you text will look like when reversed:")
'reply-with-reversed-text
;; Now switch to the second state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Now bot is in the second state.")
;; This is how we count the symbols in user input
;; and return the the previous state:
:on-update (list 'reply-with-num-symbols
(cl-telegram-bot2/term/back:back))))))))
As you can see, now bot switches between first and second states. But back
function can do more, because
this kind of actions are special and is able not only to switch current bot's state, but also to return some
results to this parent state.
To return some result we should give it as an optional argument to the cl-telegram-bot2/term/back:back
function:
(cl-telegram-bot2/term/back:back "Some result")
and to process this result, we have to specify on-result
event handler on the first state.
Here is how complete example will look like:
CL-USER> (funcall *stop-func*)
CL-USER> (defun reply-with-num-symbols (update)
(let* ((input-text
(cl-telegram-bot2/api:message-text
(cl-telegram-bot2/api:update-message update)))
(num-symbols
(length input-text)))
(cl-telegram-bot2/high:reply
(format nil "Your input has ~A chars."
num-symbols))
;; Return BACK action to return num symbols to the first state:
(cl-telegram-bot2/term/back:back num-symbols)))
CL-USER> (defun process-result (num-symbols)
(cl-telegram-bot2/high:reply
(format nil "Now we are in the first state and the second state returned ~A chars."
num-symbols))
(values))
CL-USER> (setf *stop-func*
(cl-telegram-bot2/server:start-polling
(make-test-bot *token*
:initial-state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Hello from cl-telegram-bot!")
;; Note, here we specify as a handler the list of an action
;; and a fbound symbol:
:on-update (list (cl-telegram-bot2/actions/send-text:send-text
"Here how you text will look like when reversed:")
'reply-with-reversed-text
;; Now switch to the second state
(cl-telegram-bot2/state:state
(cl-telegram-bot2/actions/send-text:send-text
"Now bot is in the second state.")
;; This is how we count the symbols in user input
;; and return it to the initial state:
:on-update 'reply-with-num-symbols))
:on-result 'process-result))))
This is all for now. In the next tutorial we'll see how to define a custom states to make some building blocks for our workflow.
API
CL-TELEGRAM-BOT2/ACTION
[package] cl-telegram-bot2/action
Classes
ACTION
####### class action
()
Functions
function call-if-action
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
[package] cl-telegram-bot2/actions/edit-message-media
Classes
EDIT-MESSAGE-MEDIA
####### class edit-message-media
(action)
Readers
####### reader caption
(edit-message-media) (:caption)
####### reader inline-keyboard
(edit-message-media) (:inline-keyboard)
####### reader media-path
(edit-message-media) (:path)
Functions
function edit-message-media
path-or-func-name &key caption inline-keyboard
CL-TELEGRAM-BOT2/ACTIONS/SEND-INVOICE
[package] cl-telegram-bot2/actions/send-invoice
Classes
SEND-INVOICE
####### class send-invoice
(action)
Readers
####### reader commands
(send-invoice) (:commands = nil)
####### reader currency
(send-invoice) (:currency)
####### reader description
(send-invoice) (:description)
####### reader on-success
(send-invoice) (:on-success)
####### reader payload
(send-invoice) (:payload)
####### reader prices
(send-invoice) (:prices)
####### reader provider-token
(send-invoice) (:provider-token)
####### reader title
(send-invoice) (:title)
Functions
function send-invoice
title description payload provider-token currency prices &key on-success commands
CL-TELEGRAM-BOT2/ACTIONS/SEND-PHOTO
[package] cl-telegram-bot2/actions/send-photo
Classes
SEND-PHOTO
####### class send-photo
(action)
Readers
####### reader caption
(send-photo) (:caption)
####### reader image-path
(send-photo) (:path)
####### reader inline-keyboard
(send-photo) (:inline-keyboard)
Functions
function send-photo
path-or-func-name &key caption inline-keyboard
CL-TELEGRAM-BOT2/ACTIONS/SEND-TEXT
[package] cl-telegram-bot2/actions/send-text
Classes
SEND-TEXT
####### class send-text
(action)
Readers
####### reader parse-mode
(send-text) (: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
(send-text) (:reply-markup = nil)
####### reader text
(send-text) (:text)
Functions
function send-text
text-or-func-name &key reply-markup parse-mode
CL-TELEGRAM-BOT2/BOT
[package] cl-telegram-bot2/bot
Macros
macro defbot
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
[package] cl-telegram-bot2/errors
Classes
TELEGRAM-ERROR
####### condition telegram-error
(error)
Readers
####### reader error-description
(telegram-error) (:DESCRIPTION = '(REQUIRED-ARGUMENT
"DESCRIPTION is required argument for TELEGRAM-ERROR class."))
CL-TELEGRAM-BOT2/GENERICS
[package] cl-telegram-bot2/generics
Generics
generic-function on-pre-checkout-query
bot query
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.
generic-function on-result
state result
This method is called when some state exits and returns a result using BACK
function.
generic-function on-state-activation
state
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.
generic-function on-state-deletion
state
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 process
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
[package] cl-telegram-bot2/high
High level API
for implementing Telegram bots.
Classes
CHAT-STATE
####### class chat-state
()
Functions
function reply
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 reply-with-photo
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
macro collect-sent-messages
&body body
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/HIGH/KEYBOARD
[package] cl-telegram-bot2/high/keyboard
Classes
CALL-CALLBACK
####### class call-callback
(inline-keyboard-button-mixin button)
Readers
####### reader callback-data
(call-callback) (:callback-data)
COPY-TEXT
####### class copy-text
(inline-keyboard-button-mixin button)
Readers
####### reader text-to-copy
(copy-text) (:text-to-copy)
OPEN-GAME
####### class open-game
(inline-keyboard-button-mixin button)
OPEN-LOGIN-URL
####### class open-login-url
(inline-keyboard-button-mixin button)
Readers
####### reader bot-username
(open-login-url) (:bot-username = nil)
####### reader forward-text
(open-login-url) (:forward-text = nil)
####### reader login-url
(open-login-url) (:login-url)
####### reader request-write-access-p
(open-login-url) (:request-write-access = nil)
OPEN-URL
####### class open-url
(inline-keyboard-button-mixin button)
Readers
####### reader url
(open-url) (:url)
OPEN-WEB-APP
####### class open-web-app
(keyboard-button-mixin inline-keyboard-button-mixin button)
Readers
####### reader web-app-url
(open-web-app) (:url)
PAY-BUTTON
####### class pay-button
(inline-keyboard-button-mixin button)
REQUEST-CHAT
####### class request-chat
(keyboard-button-mixin button)
Readers
####### reader bot-administration-rights
(request-chat) (:bot-administration-rights = nil)
####### reader bot-is-member-p
(request-chat) (:bot-is-member = nil)
####### reader chat-has-username-p
(request-chat) (:chat-has-username = nil)
####### reader chat-is-channel-p
(request-chat) (:chat-is-channel = nil)
####### reader chat-is-created-p
(request-chat) (:chat-is-created = nil)
####### reader chat-is-forum-p
(request-chat) (:chat-is-forum = nil)
####### reader request-photo-p
(request-chat) (:request-photo = nil)
####### reader request-title-p
(request-chat) (:request-title = nil)
####### reader request-username-p
(request-chat) (:request-username = nil)
####### reader user-administration-rights
(request-chat) (:user-administration-rights = nil)
####### reader users-request-id
(request-chat) (:REQUEST-ID = (REQUIRED-ARGUMENT "Argument :request-id is required."))
REQUEST-CONTACT
####### class request-contact
(keyboard-button-mixin button)
REQUEST-LOCATION
####### class request-location
(keyboard-button-mixin button)
REQUEST-POLL
####### class request-poll
(keyboard-button-mixin button)
Readers
####### reader requested-poll-type
(request-poll) (:poll-type = nil)
If "quiz" is passed, the user will be allowed to create only polls in the quiz mode. If "regular" is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type.
API
: https://core.telegram.org/bots/api#keyboardbuttonpolltype
REQUEST-USERS
####### class request-users
(keyboard-button-mixin button)
Readers
####### reader max-quantity
(request-users) (:max-quantity = 1)
####### reader request-name-p
(request-users) (:request-name = nil)
####### reader request-photo-p
(request-users) (:request-photo = nil)
####### reader request-username-p
(request-users) (:request-username = nil)
####### reader user-is-bot-p
(request-users) (:user-is-bot = nil)
####### reader user-is-premium-p
(request-users) (:user-is-premium = nil)
####### reader users-request-id
(request-users) (:REQUEST-ID = (REQUIRED-ARGUMENT "Argument :request-id is required."))
SWITCH-INLINE-QUERY-CHOOSEN-CHAT
####### class switch-inline-query-choosen-chat
(inline-keyboard-button-mixin button)
Readers
####### reader allow-bot-chats-p
(switch-inline-query-choosen-chat) (:allow-bot-chats)
####### reader allow-channel-chats-p
(switch-inline-query-choosen-chat) (:allow-channel-chats)
####### reader allow-group-chats-p
(switch-inline-query-choosen-chat) (:allow-group-chats)
####### reader allow-user-chats-p
(switch-inline-query-choosen-chat) (:allow-user-chats)
####### reader query
(switch-inline-query-choosen-chat) (:query)
SWITCH-INLINE-QUERY-CURRENT-CHAT
####### class switch-inline-query-current-chat
(inline-keyboard-button-mixin button)
Readers
####### reader inline-query
(switch-inline-query-current-chat) (:inline-query)
SWITCH-INLINE-QUERY
####### class switch-inline-query
(inline-keyboard-button-mixin button)
Readers
####### reader inline-query
(switch-inline-query) (:inline-query)
TEXT-BUTTON
####### class text-button
(keyboard-button-mixin inline-keyboard-button-mixin button)
Functions
function call-callback
title callback-data
function copy-text
button-title text-to-copy
function inline-keyboard
buttons
Returns object of CL-TELEGRAM-BOT2/API:INLOINE-KEYBOARD-MARKUP
class.
API
docs: https://core.telegram.org/bots/api#replykeyboardmarkup
function keyboard
buttons &rest rest &key is-persistent resize-keyboard one-time-keyboard input-field-placeholder selective
Returns object of CL-TELEGRAM-BOT2/API:REPLY-KEYBOARD-MARKUP
class.
API
docs: https://core.telegram.org/bots/api#replykeyboardmarkup
function open-game
button-title
function open-login-url
button-title login-url &rest rest &key forward-text bot-username request-write-access
function open-url
title url
function open-web-app
title web-app-url
function pay-button
button-title
function remove-keyboard
&key selective
function request-chat
title request-id &rest rest &key chat-is-channel chat-is-forum chat-has-username chat-is-created user-administration-rights bot-administration-rights bot-is-member request-title request-username request-photo
function request-contact
title
function request-location
title
function request-poll
title &rest rest &key poll-type
function request-users
title request-id &rest rest &key user-is-bot user-is-premium max-quantity request-name request-username request-photo
function switch-inline-query
title inline-query
function switch-inline-query-choosen-chat
title &rest rest &key query allow-user-chats allow-bot-chats allow-group-chats allow-channel-chats
function switch-inline-query-current-chat
title inline-query
function text-button
title
CL-TELEGRAM-BOT2/SERVER
[package] cl-telegram-bot2/server
Functions
function start-polling
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.
function stop-polling
bot
CL-TELEGRAM-BOT2/SPEC
[package] cl-telegram-bot2/spec
Classes
TELEGRAM-OBJECT
####### class telegram-object
()
CL-TELEGRAM-BOT2/STATE
[package] cl-telegram-bot2/state
Classes
STATE
####### class state
(state-with-commands-mixin base-state)
Readers
####### reader on-activation
(state) (:on-activation = nil)
####### reader on-callback-query
(state) (:on-callback-query = nil)
####### reader on-result
(state) (:on-result = nil)
####### reader on-update
(state) (:on-update = nil)
####### reader on-web-app-data
(state) (:on-web-app-data = nil)
Functions
function state
on-activation &key id commands on-update on-result on-callback-query on-web-app-data
CL-TELEGRAM-BOT2/STATE-WITH-COMMANDS
[package] cl-telegram-bot2/state-with-commands
Classes
COMMAND
####### class command
(base-command)
This type of command is available only in the state where it is defined.
GLOBAL-COMMAND
####### class global-command
(command)
This command will be available during in all bot states.
STATE-WITH-COMMANDS-MIXIN
####### class state-with-commands-mixin
()
Readers
####### reader state-commands
(state-with-commands-mixin) (:commands = nil)
Functions
function command
name handler &key description
function global-command
name handler &key description
CL-TELEGRAM-BOT2/STATES/ASK-FOR-CHOICE
[package] cl-telegram-bot2/states/ask-for-choice
Classes
ASK-FOR-CHOICE
####### class ask-for-choice
(base-state)
Readers
####### reader buttons
(ask-for-choice) (:buttons = nil)
####### reader delete-messages-p
(ask-for-choice) (:delete-messages = t)
Delete message with the keyboard and all warning messages when the choice was made or a new state was added to the stack.
####### reader delete-wrong-user-messages-p
(ask-for-choice) (:delete-wrong-user-messages = t)
Delete usual user messages which he might send by a mistake.
####### reader message-ids-to-delete
(ask-for-choice) (= nil)
####### reader on-success
(ask-for-choice) (:on-success = nil)
####### reader on-wrong-user-message
(ask-for-choice) (:on-wrong-user-message = nil)
####### reader prompt
(ask-for-choice) (:prompt)
####### reader var-name
(ask-for-choice) (:to = *default-var-name*)
Accessors
####### accessor message-ids-to-delete
(ask-for-choice) (= nil)
Functions
function ask-for-choice
PROMPT BUTTONS &KEY (TO *DEFAULT-VAR-NAME*) (DELETE-MESSAGES T) (DELETE-WRONG-USER-MESSAGES T) ON-SUCCESS (ON-WRONG-USER-MESSAGE (SEND-TEXT "Please push one of the buttons."))
CL-TELEGRAM-BOT2/STATES/ASK-FOR-NUMBER
[package] cl-telegram-bot2/states/ask-for-number
Classes
ASK-FOR-NUMBER
####### class ask-for-number
(base-state)
Readers
####### reader on-success
(ask-for-number) (:on-success = nil)
####### reader on-validation-error
(ask-for-number) (:on-validation-error = nil)
####### reader prompt
(ask-for-number) (:prompt)
####### reader var-name
(ask-for-number) (:to = *default-var-name*)
Functions
function ask-for-number
prompt &key (to *default-var-name*) on-success on-validation-error
CL-TELEGRAM-BOT2/STATES/BASE
[package] cl-telegram-bot2/states/base
Classes
BASE-STATE
####### class base-state
(print-items-mixin)
Readers
####### reader sent-message-ids
(base-state) (= nil)
####### reader state-id
(base-state) (:id = nil)
####### reader state-vars
(base-state) (= (dict))
Accessors
####### accessor sent-message-ids
(base-state) (= nil)
Generics
generic-function clear-state-vars
state
generic-function state-var
state var-name
Functions
function var
var-name
CL-TELEGRAM-BOT2/STATES/WAIT-FOR-PAYMENT
[package] cl-telegram-bot2/states/wait-for-payment
Classes
WAIT-FOR-PAYMENT
####### class wait-for-payment
(state-with-commands-mixin base-state)
Readers
####### reader on-success
(wait-for-payment) (:on-success = nil)
Functions
function wait-for-payment
&key on-success commands
CL-TELEGRAM-BOT2/TERM/BACK
[package] cl-telegram-bot2/term/back
Classes
BACK-TO-ID
####### class back-to-id
(back)
Readers
####### reader parent-id
(back-to-id) (:ID = (REQUIRED-ARGUMENT "Parent id is required argument."))
BACK-TO-NTH-PARENT
####### class back-to-nth-parent
(back)
Readers
####### reader parent-number
(back-to-nth-parent) (:N = (REQUIRED-ARGUMENT "Parent number required argument."))
BACK-TO
####### class back-to
(back)
Readers
####### reader state-class
(back-to) (:STATE-CLASS = (REQUIRED-ARGUMENT "State class is required argument."))
BACK
####### class back
()
Readers
####### reader result
(back) (:result = nil)
Functions
function back
&optional result
function back-to
state-class &optional result
function back-to-id
id &optional result
function back-to-nth-parent
n &optional result
CL-TELEGRAM-BOT2/UTILS
[package] cl-telegram-bot2/utils
Generics
generic-function deep-copy
object
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 arity
funcallable
function call-if-needed
value &rest args
If value is a fbound SYMBOL
, then calls as a function and then returns a result.
function from-json
string
function to-json
obj
v1
Quickstart
The system uses CLOS
to add new methods to process incoming messages.
To create a simple bot, all you need is to define on-message
method.
If you want to match on a particular command, like /help
or /make-me-happy 7 times
,
then you better to define a on-command
method.
During messages processing, function (reply "some text")
is available, which will send
given text into the right chat. Also, there is send-message
and other function exists
which allow your bot to post messages, images and other media into the any chat.
Here is example of a simple bot which reacts on the text message and /echo
command:
CL-USER> (defpackage the-bot (:use :cl :cl-telegram-bot)) #<Package "THE-BOT"> CL-USER> (in-package the-bot) #<Package "THE-BOT"> THE-BOT> (defbot echo-bot) MAKE-ECHO-BOT THE-BOT> (defmethod on-message ((bot echo-bot) text) (reply text)) #<STANDARD-METHOD ON-MESSAGE (ECHO-BOT T)> THE-BOT> (defmethod on-command ((bot echo-bot) (command (eql :help)) text) (declare (ignorable text)) (reply "Just send me any text and I'll reply with the same text.")) #<STANDARD-METHOD ON-COMMAND (ECHO-BOT (EQL :HELP) T)> THE-BOT> (defmethod on-command ((bot echo-bot) (command (eql :start)) text) (declare (ignorable text)) (reply "Welcome Lisper! Have a fun, playing with cl-telegram-bot!")) #<STANDARD-METHOD ON-COMMAND (ECHO-BOT (EQL :START) T)>
Now, stop for the minute, open your Telegram client, and create a new bot using the BotFather bot:
When you've got token, return to the REPL
and start our bot:
THE-BOT> (start-processing (make-echo-bot "5205125**********************************")
:debug t)
<INFO> [08:31:09] cl-telegram-bot core.lisp (start-processing) - Starting thread to process updates for CL-TELEGRAM-BOT/CORE::BOT: #<ECHO-BOT id=0>
#<PROCESS telegram-bot(33) [Reset] #x30200709246D>
THE-BOT>
This will start a new thread for processing incoming messages.
Now, find your bot in the Telegram client:
And start communicating with him:
API
CL-TELEGRAM-BOT/BOT
[package] cl-telegram-bot/bot
Classes
BOT
####### class bot
()
Readers
####### reader api-uri
(bot) (:API-URI = "https://api.telegram.org/")
####### reader bot-info
(bot) (= nil)
This slot will be filled with cl-telegram-bot/user:user
object on first access using a call to cl-telegram-bot/user:get-me
function.
####### reader debug-mode
(bot) (:debug-mode = nil)
When debug mode is T, then interactive debugger will be called on each error.
####### reader file-endpoint
(bot) (:file-endpoint = nil)
HTTPS
file-endpoint
####### reader get-endpoint
(bot) (:endpoint)
HTTPS
endpoint
####### reader get-last-update-id
(bot) (= 0)
Update id
####### reader sent-commands-cache
(bot) (= nil)
Command processing code will use this cache to update commands list on the server
when a new method for cl-telegram-bot/entities/command:on-command
generic-function is defined.
This slot is for internal use.
####### reader token
(bot) (:token = nil)
Bot token given by BotFather
Accessors
####### accessor api-uri
(bot) (:API-URI = "https://api.telegram.org/")
####### accessor debug-mode
(bot) (:debug-mode = nil)
When debug mode is T, then interactive debugger will be called on each error.
####### accessor file-endpoint
(bot) (:file-endpoint = nil)
HTTPS
file-endpoint
####### accessor get-last-update-id
(bot) (= 0)
Update id
####### accessor sent-commands-cache
(bot) (= nil)
Command processing code will use this cache to update commands list on the server
when a new method for cl-telegram-bot/entities/command:on-command
generic-function is defined.
This slot is for internal use.
####### accessor token
(bot) (:token = nil)
Bot token given by BotFather
Macros
macro defbot
name &optional slots options
Use this macro to define a class of your Telegram bot.
CL-TELEGRAM-BOT/CALLBACK
[package] cl-telegram-bot/callback
Classes
CALLBACK
####### class callback
()
Readers
####### reader callback-data
(callback) (:data)
####### reader callback-id
(callback) (:id)
####### reader callback-message
(callback) (:message)
Generics
generic-function make-callback
bot callback-data
Called when user clicks callback button. Should return an instance of callback
class.
Application may override this method to return objects of different callback classes depending on
callback-data string. This way it mab be easier to define more specific methods for
on-callback
generic-function.
generic-function on-callback
bot callback
Called when user clicks callback button. Second argument is an object of CALLBACK
type.
CL-TELEGRAM-BOT/CHAT
[package] cl-telegram-bot/chat
Classes
CHANNEL
####### class channel
(base-group)
CHAT
####### class chat
()
Readers
####### reader get-chat-id
(chat) (:id)
####### reader get-has-protected-content
(chat) (:has-protected-content)
####### reader get-message-auto-delete-time
(chat) (:message-auto-delete-time)
####### reader get-raw-data
(chat) (:raw-data)
####### reader get-username
(chat) (:username)
GROUP
####### class group
(base-group)
PRIVATE-CHAT
####### class private-chat
(chat)
Readers
####### reader get-bio
(private-chat) (:bio)
####### reader get-first-name
(private-chat) (:first-name)
####### reader get-has-private-forwards
(private-chat) (:has-private-forwards)
####### reader get-last-name
(private-chat) (:last-name)
SUPER-GROUP
####### class super-group
(base-group)
Readers
####### reader get-can-set-sticker-set
(super-group) (:can-set-sticker-set)
####### reader get-join-by-request
(super-group) (:join-by-request)
####### reader get-join-to-send-messages
(super-group) (:join-to-send-messages)
####### reader get-slow-mode-delay
(super-group) (:slow-mode-delay)
####### reader get-sticker-set-name
(super-group) (:sticker-set-name)
Generics
generic-function get-chat
obj
Returns a chat associated with object.
Object could be a message, update, callback, etc. Should return an object of chat
class or NIL
.
Some types of updates aren't bound to a chat. In this case a method should return NIL
.
Functions
function delete-chat-photo
bot-var1 chat
https://core.telegram.org/bots/api#deletechatphoto
function export-chat-invite-link
bot-var1 chat
https://core.telegram.org/bots/api#exportchatinvitelink
function get-chat-administrators
bot-var1 chat
https://core.telegram.org/bots/api#getchatadministrators
function get-chat-by-id
bot-var1 chat-id
https://core.telegram.org/bots/api#getchat
function get-chat-member
bot-var1 chat user-id
https://core.telegram.org/bots/api#getchatmember
function get-chat-members-count
bot-var1 chat
https://core.telegram.org/bots/api#getchatmemberscount
function kick-chat-member
bot-var1 chat user-id until-date
https://core.telegram.org/bots/api#kickchatmember
function leave-chat
bot-var1 chat
https://core.telegram.org/bots/api#leavechat
function pin-chat-message
bot-var1 chat message-id disable-notification
https://core.telegram.org/bots/api#pinchatmessage
function promote-chat-member
bot-var1 chat user-id can-change-info can-post-messages can-edit-messages can-delete-messages can-invite-users can-restrict-members can-pin-messages can-promote-members
https://core.telegram.org/bots/api#promotechatmember
function restrict-chat-member
bot-var1 chat user-id until-date can-send-messages can-send-media-messages can-send-other-messages can-add-web-page-previews
https://core.telegram.org/bots/api#restrictchatmember
function send-chat-action
bot-var1 chat action
https://core.telegram.org/bots/api#sendchataction
function set-chat-description
bot-var1 chat description
https://core.telegram.org/bots/api#setchatdescription
function set-chat-photo
bot-var1 chat photo
https://core.telegram.org/bots/api#setchatphoto
function set-chat-title
bot-var1 chat title
https://core.telegram.org/bots/api#setchattitle
function unban-chat-member
bot-var1 chat user-id
https://core.telegram.org/bots/api#unbanchatmember
function unpin-chat-message
bot-var1 chat
https://core.telegram.org/bots/api#unpinchatmessage
CL-TELEGRAM-BOT/CORE
[package] cl-telegram-bot/core
Classes
REPLY
####### class reply
(response-with-text)
Generics
generic-function on-command
bot command rest-text
This method will be called for each command. First argument is a keyword. If user input was /save_note, then first argument will be :save-note.
By default, logs call and does nothing.
generic-function on-message
bot text
This method gets called with raw text from the message. By default it does nothing.
Functions
function reply
text &rest args &key parse-mode disable-web-page-preview disable-notification reply-to-message-id reply-markup (immediately *reply-immediately*)
Works like a send-message
, but only when an incoming message is processed.
Automatically sends reply to a chat from where current message came from.
function start-processing
BOT &KEY DEBUG (DELAY-BETWEEN-RETRIES 10) (THREAD-NAME "telegram-bot")
function stop-processing
bot
Macros
macro defbot
name &optional slots options
Use this macro to define a class of your Telegram bot.
CL-TELEGRAM-BOT/ENTITIES/COMMAND
[package] cl-telegram-bot/entities/command
Classes
BOT-COMMAND
####### class bot-command
(entity)
Readers
####### reader bot-username
(bot-command) (:bot-username)
####### reader get-command
(bot-command) (:command)
####### reader get-rest-text
(bot-command) (:rest-text)
Generics
generic-function on-command
bot command rest-text
This method will be called for each command. First argument is a keyword. If user input was /save_note, then first argument will be :save-note.
By default, logs call and does nothing.
CL-TELEGRAM-BOT/ENTITIES/GENERIC
[package] cl-telegram-bot/entities/generic
Generics
generic-function make-entity-internal
entity-type payload data
Extendable protocol to support entities of different kinds. First argument is a keyword, denoting a type of the entity. Payload is an object of type `message'. And data is a plist with data, describing the entity.
Functions
function make-entity
payload data
CL-TELEGRAM-BOT/ENVELOPE
[package] cl-telegram-bot/envelope
Classes
CHANNEL-POST
####### class channel-post
(envelope)
This container wraps cl-telegram-bot/message:message
when somebody sends a message to a channel.
EDITED-CHANNEL-POST
####### class edited-channel-post
(envelope)
This container wraps cl-telegram-bot/message:message
when somebody edits a message in a channel.
EDITED-MESSAGE
####### class edited-message
(envelope)
This container wraps cl-telegram-bot/message:message
when user edits a message.
ENVELOPE
####### class envelope
()
This is the container for a message. From the type of container we can understand if this message was sent to a channel or maybe edited, etc.
Readers
####### reader wrapped-message
(envelope) (:message)
Functions
function channel-post-p
Returns T if current message was posted to a channel.
function edited-message-p
Returns T if current message is an update for existing message in the channel of group chat.
CL-TELEGRAM-BOT/INLINE-KEYBOARD
[package] cl-telegram-bot/inline-keyboard
Classes
CALLBACK-BUTTON
####### class callback-button
(inline-keyboard-button)
Readers
####### reader callback-button-data
(callback-button) (:data)
INLINE-KEYBOARD-BUTTON
####### class inline-keyboard-button
()
Base class for all inline keyboard buttons.
API
: https://core.telegram.org/bots/api#inlinekeyboardbutton
Readers
####### reader button-text
(inline-keyboard-button) (:text)
INLINE-KEYBOARD
####### class inline-keyboard
()
Represents an inline keyboard as specified in API
https://core.telegram.org/bots/api#inlinekeyboardmarkup.
Readers
####### reader keyboard-rows
(inline-keyboard) (:rows = nil)
URL-BUTTON
####### class url-button
(inline-keyboard-button)
Readers
####### reader button-url
(url-button) (:data)
Functions
function answer-callback-query
bot callback &key text show-alert url
https://core.telegram.org/bots/api#answercallbackquery
function callback-button
text data
Creates a button which will call a callback.
function inline-keyboard
rows
Returns an inline keyboard which can be passed
to cl-telegram-bot/response:reply
(1
2
) as REPLY-MARKUP
argument.
Each row should be a list of inline-keyboard-button
objects or a single
object of this class. In latter case, such row will have only one button.
function url-button
text url
Creates a button which will open an url.
CL-TELEGRAM-BOT/MARKUP
[package] cl-telegram-bot/markup
Generics
generic-function to-markup
obj
Transforms object into markup of Telegram API
.
Methods of this class should return a hash-table, representing OBJ
in terms of Telegram API
.
CL-TELEGRAM-BOT/MESSAGE
[package] cl-telegram-bot/message
Classes
ANIMATION-MESSAGE
####### class animation-message
(file-message)
ANIMATION
####### class animation
(file temporal spatial)
AUDIO-MESSAGE
####### class audio-message
(file-message)
AUDIO
####### class audio
(file temporal)
Readers
####### reader get-performer
(audio) (:performer)
Performer of the audio as defined by sender or by audio tags.
####### reader get-title
(audio) (:title)
Title of the audio as defined by sender or by audio tags.
DOCUMENT-MESSAGE
####### class document-message
(file-message)
DOCUMENT
####### class document
(file)
FILE-MESSAGE
####### class file-message
(message)
Readers
####### reader get-file
(file-message) (:file)
FILE
####### class file
()
Readers
####### reader get-file-id
(file) (:file-id)
Identifier for this file, which can be used to download or reuse the file.
####### reader get-file-name
(file) (:file-name)
Original filename as defined by sender.
####### reader get-file-size
(file) (:file-size)
File size in bytes.
####### reader get-file-unique-id
(file) (:file-unique-id)
Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
####### reader get-mime-type
(file) (:mime-type)
MIME
type of the file as defined by sender.
MESSAGE
####### class message
()
Readers
####### reader get-caption
(message) (:caption)
Caption for the animation, audio, document, photo, video or voice.
####### reader get-chat
(message) (:chat)
####### reader get-entities
(message) (:entities = nil)
####### reader get-forward-from
(message) (:forward-from)
For forwarded messages, sender of the original message.
####### reader get-forward-from-chat
(message) (:forward-from-chat)
For messages forwarded from channels or from anonymous administrators, information about the original sender chat.
####### reader get-forward-sender-name
(message) (:forward-sender-name)
For forwarded messages, sender of the original message.
####### reader get-message-id
(message) (:id)
####### reader get-raw-data
(message) (:raw-data)
####### reader get-sender-chat
(message) (:sender-chat)
Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group.
####### reader get-text
(message) (:text)
PHOTO-MESSAGE
####### class photo-message
(file-message)
Readers
####### reader get-photo-options
(photo-message) (:photo-options)
PHOTO
####### class photo
(file spatial)
REPLY
####### class reply
(message)
Readers
####### reader get-reply-to-message
(reply) (:reply-to-message)
SPATIAL
####### class spatial
()
Readers
####### reader get-height
(spatial) (:height)
File height as defined by sender.
####### reader get-width
(spatial) (:width)
File width as defined by sender.
STICKER-MESSAGE
####### class sticker-message
(file-message)
STICKER
####### class sticker
(file spatial)
Readers
####### reader get-emoji
(sticker) (:emoji)
Emoji associated with the sticker
####### reader get-is-animated
(sticker) (:is-animated)
True if the sticker is animated.
####### reader get-is-video
(sticker) (:is-video)
True if the sticker is a video sticker.
####### reader get-set-name
(sticker) (:set-name)
Name of the sticker set to which the sticker belongs.
TEMPORAL
####### class temporal
()
Readers
####### reader get-duration
(temporal) (:duration)
Duration of the file in seconds as defined by sender.
UNISPATIAL
####### class unispatial
()
Readers
####### reader get-length
(unispatial) (:length)
VIDEO-MESSAGE
####### class video-message
(file-message)
VIDEO-NOTE-MESSAGE
####### class video-note-message
(file-message)
VIDEO-NOTE
####### class video-note
(file temporal unispatial)
VIDEO
####### class video
(file temporal spatial)
VOICE-MESSAGE
####### class voice-message
(file-message)
VOICE
####### class voice
(file temporal)
Generics
generic-function on-message
bot text
This method gets called with raw text from the message. By default it does nothing.
generic-function send-animation
bot chat animation &rest options &key caption parse-mode caption-entities duration width height thumb disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
Sends animation to a chat.
generic-function send-audio
bot chat audio &rest options &key caption parse-mode caption-entities duration performer title thumb disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
generic-function send-document
bot chat document &rest options &key caption parse-mode caption-entities disable-content-type-detection thumb disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
generic-function send-photo
bot chat photo &rest options &key caption parse-mode caption-entities disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
generic-function send-sticker
bot chat sticker &rest options &key disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
A function to send sticker.
generic-function send-video
bot chat video &rest options &key caption parse-mode caption-entities duration width height thumb disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
generic-function send-video-note
bot chat video-note &rest options &key caption parse-mode caption-entities duration length thumb disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
generic-function send-voice
bot chat voice &rest options &key caption parse-mode caption-entities duration disable-notification protect-content reply-to-message-id allow-sending-without-reply reply-markup
Functions
function delete-message
bot chat message
https://core.telegram.org/bots/api#deletemessage
function forward-message
bot chat from-chat message &key disable-notification
https://core.telegram.org/bots/api#forwardmessage
function get-current-bot
Returns a bot to which message was addressed.
function get-current-chat
Returns a chat where currently processing message was received.
function get-current-message
Returns currently processed message.
function make-message
data
function send-message
bot chat text &rest options &key parse-mode disable-web-page-preview disable-notification reply-to-message-id (autosplit nil) reply-markup
https://core.telegram.org/bots/api#sendmessage
CL-TELEGRAM-BOT/NETWORK
package cl-telegram-bot/network
Classes
REQUEST-ERROR
####### condition request-error
(error)
Readers
####### reader what
(request-error) (:what)
Functions
function make-request
bot name &rest options &key (streamp nil) (timeout 3) &allow-other-keys
Perform HTTP
request to 'name API
method with 'options JSON
-encoded object.
function set-proxy
proxy
CL-TELEGRAM-BOT/PAYMENTS
[package] cl-telegram-bot/payments
Generics
generic-function on-pre-checkout-query
bot query
Called when user enters payment method credentials and hit "Pay" button. Second argument is an object of PRE-CHECKOUT-QUERY
type.
A method should respond with with a call to answer-pre-checkout-query
function.
Functions
function answer-pre-checkout-query
bot pre-checkout-query &key error-message
If ERROR-MESSAGE
argument was given, then response considered is not OK
and transaction will be cancelled.
https://core.telegram.org/bots/api#answerprecheckoutquery
function answer-shipping-query
b shipping-query-id ok &key shipping-options error-message
https://core.telegram.org/bots/api#answershippingquery
function send-invoice
b chat-id title description payload provider-token start-parameter currency prices &key photo-url photo-size photo-width photo-height need-name need-phone-number need-email need-shipping-address is-flexible disable-notification reply-to-message-id reply-markup
https://core.telegram.org/bots/api#sendinvoice
CL-TELEGRAM-BOT/PIPELINE
package cl-telegram-bot/pipeline
Generics
generic-function process
bot 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(update) process(update.payload) For each entity in payload: process(entity)
CL-TELEGRAM-BOT/RESPONSE
[package] cl-telegram-bot/response
Classes
ALERT
####### class alert
(response-with-text)
NOTIFY
####### class notify
(response-with-text)
OPEN-URL
####### class open-url
(response)
Readers
####### reader url-to-open
(open-url) (:text)
REPLY
####### class reply
(response-with-text)
RESPONSE-WITH-TEXT
####### class response-with-text
(response)
Readers
####### reader response-text
(response-with-text) (:text)
RESPONSE
####### class response
()
Readers
####### reader rest-args
(response) (:args)
Functions
function alert
text
Works like a send-message
, but only when an incoming message is processed.
Automatically sends reply to a chat from where current message came from.
function notify
text
Works like a send-message
, but only when an incoming message is processed.
Automatically sends reply to a chat from where current message came from.
function open-url
url
Works like a send-message
, but only when an incoming message is processed.
Automatically sends reply to a chat from where current message came from.
function reply
text &rest args &key parse-mode disable-web-page-preview disable-notification reply-to-message-id reply-markup (immediately *reply-immediately*)
Works like a send-message
, but only when an incoming message is processed.
Automatically sends reply to a chat from where current message came from.
CL-TELEGRAM-BOT/RESPONSE-PROCESSING
[package] cl-telegram-bot/response-processing
Classes
INTERRUPT-PROCESSING
####### condition interrupt-processing
()
Generics
generic-function process-response
bot message response
Processes immediate responses of different types.
Functions
function interrupt-processing
CL-TELEGRAM-BOT/UPDATE
[package] cl-telegram-bot/update
Classes
UPDATE
####### class update
()
Readers
####### reader get-payload
(update) (:payload)
####### reader get-raw-data
(update) (:raw-data)
####### reader get-update-id
(update) (:id)
Generics
generic-function process-updates
bot
By default, this method starts an infinite loop and fetching new updates using long polling.
Functions
function make-update
data
CL-TELEGRAM-BOT/USER
[package] cl-telegram-bot/user
Classes
USER
####### class user
()
Readers
####### reader bot-p
(user) (:is-bot)
####### reader can-connect-to-business-p
(user) (:can-connect-to-business = nil)
####### reader can-join-groups-p
(user) (:can-join-groups = nil)
####### reader can-read-all-group-messages-p
(user) (:can-read-all-group-messages = nil)
####### reader first-name
(user) (:first-name)
####### reader is-premium
(user) (:is-premium = nil)
####### reader language-code
(user) (:language-code = nil)
####### reader last-name
(user) (:last-name = nil)
####### reader raw-data
(user) (:raw-data)
####### reader supports-inline-queries-p
(user) (:supports-inline-queries = nil)
####### reader user-id
(user) (:id)
####### reader username
(user) (:username = nil)
Generics
generic-function get-user-info
obj
Returns a user
object related to the object.
If object is not bound to a user, then NIL
should be returned.
Functions
function get-me
bot
https://core.telegram.org/bots/api#getme
CL-TELEGRAM-BOT/UTILS
[package] cl-telegram-bot/utils
Functions
function api-response-to-plist
plist
Transforms a plist with keys like :|foo_bar| into a plist with keys like :foo-bar.
This can be useful to pass data into CL
object contructors.
function make-keyword
text
function obfuscate
url
function split-by-lines
text &key (max-size 4096) (trim-whitespaces-p t)
Credits
- Rei – initial version.
- Alexander Artemenko – large refactoring, usage of
CLOS
classes, etc.
[generated by 40ANTS-DOC]
Dependencies (33)
- 40ants-asdf-system
- alexandria
- anaphora
- arrows
- bordeaux-threads
- ci
- clack
- cl-json
- closer-mop
- cl-ppcre
- cl-str
- cl-strings
- cl-telegram-bot-media
- dexador
- doc
- docs-builder
- jonathan
- kebab
- lambda-fiddle
- log4cl
- log4cl-extras
- logging
- named-readtables
- ningle
- njson
- pythonic-string-reader
- quri
- rove
- serapeum
- spinneret
- trivial-arguments
- trivial-backtrace
- yason