From 941835c331f16846da6c65f466728e2ed807ca4d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 13 Mar 2016 23:07:59 +0100 Subject: Add extension build and install instructions --- example/echo.scm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 example/echo.scm (limited to 'example/echo.scm') diff --git a/example/echo.scm b/example/echo.scm new file mode 100644 index 0000000..7afd5ae --- /dev/null +++ b/example/echo.scm @@ -0,0 +1,31 @@ +(require-extension telebot + (prefix telebot telebot:)) + +(use data-structures) + +(define (resolve-query query tree) + (fold (lambda (x y) (alist-ref x y)) + tree + query)) + +(define token (car (command-line-arguments))) + +(define (print-message msg) + (print (resolve-query '(message from first_name) msg) + ": " + (resolve-query '(message text) msg) + " (" + (resolve-query '(update_id) msg) + ")")) + +(define (echo-message msg) + (let ((chat_id (resolve-query '(message from id) msg)) + (text (resolve-query '(message text) msg))) + (telebot:sendMessage token + chat_id: chat_id + text: text))) + +(telebot:pollUpdates token + (lambda (u) + (begin (print-message u) + (echo-message u)))) -- cgit v1.2.3