blob: 1bc357b35da40833c774e4140b2ba67a9ebb3c50 (
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
32
33
34
|
(include "telebot.scm")
(import (prefix telebot telebot:))
(use vector-lib)
(define (assure-list value)
(if (list? value)
value
(list)))
(define (find-pair symbol nodes)
(find (lambda (x) (equal? symbol (car x)))
(filter pair? nodes)))
(define (resolve-query query tree)
(fold-right (lambda (x y) (find-pair x (assure-list y)))
tree
(reverse query)))
(define (updates-for-each func updates)
(vector-for-each (lambda (i u) (func u))
(cdr updates)))
(define token (car (command-line-arguments)))
(updates-for-each (lambda (u)
(print (cdr (resolve-query (list 'message 'from 'first_name) u))
": "
(cdr (resolve-query (list 'message 'text) u))
" ("
(cdr (resolve-query (list 'update_id) u))
")"))
(resolve-query (list 'result)
(telebot:get-updates token)))
|