aboutsummaryrefslogtreecommitdiff
path: root/telebot.scm
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-03-10 14:11:36 +0100
committerAdrian Kummerlaender2016-03-10 14:11:36 +0100
commit376bd6ab78276fe7e33662bd89cfdb5fac6052b4 (patch)
treebd44f4cc7add2dba648ab5dbd855508ee38632e5 /telebot.scm
downloadTelebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar.gz
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar.bz2
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar.lz
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar.xz
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.tar.zst
Telebot-376bd6ab78276fe7e33662bd89cfdb5fac6052b4.zip
Basic example query of the Telegram Bot API using Scheme
Diffstat (limited to 'telebot.scm')
-rw-r--r--telebot.scm27
1 files changed, 27 insertions, 0 deletions
diff --git a/telebot.scm b/telebot.scm
new file mode 100644
index 0000000..6d6792d
--- /dev/null
+++ b/telebot.scm
@@ -0,0 +1,27 @@
+(module telebot (get-me get-updates send-message)
+ (import chicken scheme)
+ (use openssl)
+ (use http-client)
+ (use medea)
+
+ (define api-base "https://api.telegram.org/bot")
+
+ (define (get-query-url token method)
+ (string-append api-base token "/" method))
+
+ (define (get-me token)
+ (with-input-from-request (get-query-url token "getMe")
+ #f
+ read-json))
+
+ (define (get-updates token)
+ (with-input-from-request (get-query-url token "getUpdates")
+ #f
+ read-json))
+
+ (define (send-message token user message)
+ (with-input-from-request (get-query-url token "sendMessage")
+ (list (cons 'chat_id user)
+ (cons 'text message))
+ read-json))
+)