... is a basic Chicken Scheme module to ease the development of bots interfacing with the Telegram Bot API.
In this context basic means that the module currently consists primarily of raw HTTP API calls hidden behind analogously named functions and JSON deserialization provided by the http-client respectively medea eggs.
The maintanance of these API wrappers is simplified by an appropriate Scheme macro that reduces the implementation of new API methods to basically slightly rewriting the documentation.
To simplify the implementation of bots a set of framework functions implementing common usage patterns is provided.
example/echo.scm implements a bot that echoes all messages back to their sender.
example/guess.scm implements a simple number guessing game.
All basic API wrappers are named the same as their method name and require the bot's token as their first argument. Further parameters are expected as named key value pairs. Note that the library currently only verifies that all required parameters are supplied at all while type verification is left to Telegram's server side logic.
(sendMessage token chat_id: chat_id text: text)
All API wrappers return the raw deserialized JSON results as to not limit the options for further parsing unnecessarily.
One framework function provided by this library is
poll-updates which enables passing updates acquired via long polling of
getUpdates to an arbitrary function as follows:
(poll-updates token (lambda (u) (begin (print-message u) (echo-message u))))
The common pattern of managing user specific conversations is supported via
make-conversation-manager. This procedure instantiates a closure to be passed to e.g.
poll-updates using a given token and conversation handler. All updates are then automatically distributed to an appropriate conversation handler that may in turn be a closure maintaining conversation-specific state.
example/guess.scm implements a practical bot based on this pattern.
Based on the official documentation.
The only missing method is
setWebhook as this kind of interfacing with Telegram is currently out of scope of this library. Should this be required an appropriate wrapper may be easily generated using the
wrap-api-method macro described by the module.
git clone https://github.com/KnairdA/Telebot.git cd Telebot chicken-install -s