dasTelegram
March 8, 2026 · View on GitHub
Telegram Bot API bindings for daslang.
Zero-DOM JSON pipeline — uses sprint_json for requests and sscan_json for responses. No read_json/from_JV overhead.
Requirements
- daslang with dasHV module enabled (
DAS_HV_DISABLED=OFF) sscan_json/sprint_jsonbuiltins (daslang >= 0.5)
Install
daspkg install github.com/borisbat/dasTelegram
Or clone manually into your project's modules/dasTelegram/.
Usage
options gen2
options rtti
options persistent_heap
require telegram/tbot
require fio
[export]
def main() {
var token = ""
unsafe {
token = get_env_variable("TELEGRAM_BOT_TOKEN")
}
telegram_set_configuration(configuration(token = token))
// get bot info
var me <- telegram_getMe()
print("Bot: {me.username}\n")
// echo bot loop
var offset = 0l
while (true) {
var updates <- telegram_getUpdates(get_updates(offset = offset, timeout = 30l))
for (u in updates) {
offset = u.update_id + 1l
if (u.message != null) {
unsafe {
let msg & = *u.message
if (!empty(msg.text)) {
telegram_sendMessage(send_message(chat_id = "{msg.chat.id}", text = msg.text))
}
}
}
}
}
}
Regenerating API types
The telegram/tbotapi.das file is generated from the Telegram Bot API spec. To regenerate:
- Download
api.jsonfrom the spec repo - Place it in
telegram/api.json - Run:
daslang telegram/generate.das --
Files
telegram/tbot.das— bot API wrapper (configuration, HTTP calls, JSON pipeline)telegram/tbotapi.das— generated struct types with@optional/@renameannotationstelegram/generate.das— code generator.das_module— module registration forrequire telegram/tbot.das_package— daspkg manifestexamples/echo_bot.das— echo bot exampleexamples/test_api.das— API smoke test