From 94f572847c844608adf43bbac2bfc52838fc226b Mon Sep 17 00:00:00 2001 From: Christoph Lange Date: Fri, 20 Apr 2018 15:00:53 +0200 Subject: 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. --- telebot.scm | 15 ++++++++++----- 1 file 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)) -- cgit v1.2.3