aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lange2018-04-20 15:00:53 +0200
committerChristoph Lange2018-04-20 15:00:53 +0200
commit94f572847c844608adf43bbac2bfc52838fc226b (patch)
treebff63d87051bb7787f194c40fef4d0e91ead8962
parentf80974375fb50d760920b6e2eda611fc6f63ac51 (diff)
downloadTelebot-94f572847c844608adf43bbac2bfc52838fc226b.tar
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.tar.gz
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.tar.bz2
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.tar.lz
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.tar.xz
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.tar.zst
Telebot-94f572847c844608adf43bbac2bfc52838fc226b.zip
Change 'update-predicate' to reach deeper into update
Using 'resolve-query' instead of pure alist-type, we can reach deeper into the update. Added: - is-text? - is-location? using this. NB: since I use 'message' as key, those will fail when applied on e.g. 'updated_message'. Work left to do.
-rw-r--r--telebot.scm15
1 files changed, 10 insertions, 5 deletions
diff --git a/telebot.scm b/telebot.scm
index 963b829..3970588 100644
--- a/telebot.scm
+++ b/telebot.scm
@@ -28,6 +28,8 @@
is-edited_message?
is-inline_query?
is-chosen_inline_result?
+ is-text?
+ is-location?
poll-updates
make-conversation-manager)
(import chicken scheme)
@@ -247,12 +249,15 @@
(define (update-predicate type)
(lambda (update)
- (not (equal? #f (alist-ref type update)))))
+ (not (equal? #f (resolve-query type update)))))
- (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)))
+ (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 (poll-updates token handler)
(let ((offset 0))