aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerländer2018-05-01 20:43:33 +0200
committerGitHub2018-05-01 20:43:33 +0200
commitcbb82c090e249f2d67b7e97ecb167cf558deb956 (patch)
treeed8b72b905586311ed9d38bef7f84907df9325f6
parente8e5c001d462f071d4cc1803bd749a6f667e22ca (diff)
parentebc0c51cdf832bb8a0fe0e4b9cc9bff8fab28e4e (diff)
downloadTelebot-master.tar
Telebot-master.tar.gz
Telebot-master.tar.bz2
Telebot-master.tar.lz
Telebot-master.tar.xz
Telebot-master.tar.zst
Telebot-master.zip
Merge pull request #2 from recumbentbirder/clean-message-checkHEADmaster
Abstract 'is-message?': returns #t for message and edited_message
-rw-r--r--telebot.scm20
1 files changed, 11 insertions, 9 deletions
diff --git a/telebot.scm b/telebot.scm
index 3970588..eda1a0e 100644
--- a/telebot.scm
+++ b/telebot.scm
@@ -57,7 +57,7 @@
cleaned-parameters)))
(define (resolve-query query tree)
- (fold (lambda (x y) (alist-ref x y))
+ (fold (lambda (x y) (alist-ref x y eqv? '()))
tree
query))
@@ -246,18 +246,20 @@
next_offset))
;;; framework
+ (define (is-update-type? type update)
+ (not (equal? '() (resolve-query type update))))
- (define (update-predicate type)
+ (define (update-predicate types)
(lambda (update)
- (not (equal? #f (resolve-query type update)))))
+ (any (lambda (type) (is-update-type? type update)) types)))
- (define is-message? (update-predicate '(message)))
- (define is-edited_message? (update-predicate '(edited_message)))
- (define is-inline_query? (update-predicate '(inline_query)))
- (define is-chosen_inline_result? (update-predicate '(chosen_inline_result)))
+ (define is-message? (update-predicate '((message) (edited_message)) ))
+ (define is-edited_message? (update-predicate '((edited_message)) ))
+ (define is-inline_query? (update-predicate '((inline_query)) ))
+ (define is-chosen_inline_result? (update-predicate '((chosen_inline_result)) ))
- (define is-text? (update-predicate '(message text)))
- (define is-location? (update-predicate '(message location)))
+ (define is-text? (update-predicate '((message text) (edited_message text)) ))
+ (define is-location? (update-predicate '((message location) (edited_message location)) ))
(define (poll-updates token handler)
(let ((offset 0))