aboutsummaryrefslogtreecommitdiff
path: root/bot.scm
blob: 62b45a8249fab8612395dc4abc7271a929660183 (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
(include "telebot.scm")
(import (prefix telebot telebot:))

(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 token (car (command-line-arguments)))

(print (resolve-query (list 'result 'username)
                      (telebot:get-me token)))

(pretty-print (resolve-query (list 'result)
                             (telebot:get-updates token)))