aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-03-14 18:47:49 +0100
committerAdrian Kummerlaender2016-03-14 18:47:49 +0100
commit1c1825eee55ecb098e8b0ad6dba6bbaced7092cf (patch)
tree009694f57115e29e8a6db4cdcfa1a40b9a2c5197
parent8be93e3e1b0a8504ff1ad4c9dce1359307a15fa9 (diff)
downloadTelebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar.gz
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar.bz2
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar.lz
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar.xz
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.tar.zst
Telebot-1c1825eee55ecb098e8b0ad6dba6bbaced7092cf.zip
Use appropriate function for update query in `pollUpdates`
-rw-r--r--telebot.scm19
1 files changed, 10 insertions, 9 deletions
diff --git a/telebot.scm b/telebot.scm
index c30d095..5e95e1d 100644
--- a/telebot.scm
+++ b/telebot.scm
@@ -20,6 +20,7 @@
(use medea)
(use loops)
(use vector-lib)
+ (use data-structures)
(define-constant api-base "https://api.telegram.org/bot")
@@ -156,13 +157,13 @@
;;; framework
(define (pollUpdates token handler)
- (define offset 0)
- (define process (lambda (i u)
- (begin (handler u)
- (set! offset (+ 1 (cdr (assv 'update_id u)))))))
- (do-forever
- (vector-for-each process
- (cdr (assv 'result (getUpdates token
- offset: offset
- timeout: 60))))))
+ (let ((offset 0))
+ (do-forever
+ (vector-for-each (lambda (i u)
+ (handler u)
+ (set! offset (+ 1 (alist-ref 'update_id u))))
+ (alist-ref 'result
+ (getUpdates token
+ offset: offset
+ timeout: 60))))))
)