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 --- LICENSE | 20 ++++++++++++++++++++ bot.scm | 31 ------------------------------- example/echo.scm | 31 +++++++++++++++++++++++++++++++ telebot.meta | 11 +++++++++++ telebot.setup | 7 +++++++ 5 files changed, 69 insertions(+), 31 deletions(-) create mode 100644 LICENSE delete mode 100644 bot.scm create mode 100644 example/echo.scm create mode 100644 telebot.meta create mode 100644 telebot.setup diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0c3d64e --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2016 Adrian Kummerländer + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bot.scm b/bot.scm deleted file mode 100644 index 79b1b6e..0000000 --- a/bot.scm +++ /dev/null @@ -1,31 +0,0 @@ -(include "telebot.scm") -(import (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)))) 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)))) diff --git a/telebot.meta b/telebot.meta new file mode 100644 index 0000000..d8c3ffb --- /dev/null +++ b/telebot.meta @@ -0,0 +1,11 @@ +((license "MIT") + (category web) + + (needs openssl + http-client + medea + loops + vector-lib) + + (author "Adrian Kummerländer") + (synopsis "Basic wrapper of the Telegram Bot API.")) diff --git a/telebot.setup b/telebot.setup new file mode 100644 index 0000000..e47eae7 --- /dev/null +++ b/telebot.setup @@ -0,0 +1,7 @@ +(compile -s -O2 -d1 telebot -j telebot) +(compile -s -O2 -d0 telebot.import.scm) + +(install-extension + 'telebot + '("telebot.so" "telebot.import.so") + '((version "1.0"))) -- cgit v1.2.3