blob: 79b1b6e1a19b2444b13d8bef79189c9b252c546c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
(include "telebot.scm")
(import (prefix telebot telebot:))
(use data-structures)
(define (resolve-query query tree)
(fold (lambda (x y) (alist-ref x y))
tree
query))
(define token (car (command-line-arguments)))
(define (print-message msg)
(print (resolve-query '(message from first_name) msg)
": "
(resolve-query '(message text) msg)
" ("
(resolve-query '(update_id) msg)
")"))
(define (echo-message msg)
(let ((chat_id (resolve-query '(message from id) msg))
(text (resolve-query '(message text) msg)))
(telebot:sendMessage token
chat_id: chat_id
text: text)))
(telebot:pollUpdates token
(lambda (u)
(begin (print-message u)
(echo-message u))))
|