diff --git a/miscellaneous/suckless-conf/examples/telegram-bot/send-update2.ss b/miscellaneous/suckless-conf/examples/telegram-bot/send-update2.ss new file mode 100644 index 00000000..c5ef6fc2 --- /dev/null +++ b/miscellaneous/suckless-conf/examples/telegram-bot/send-update2.ss @@ -0,0 +1,27 @@ +import (sym [env HOME] /dmz-data/telegram/resources.ss) + +; (println hbs2-bot-debug) + +(define bot-id hbs2-bot-id) + +(define (send-debug-message r . mess) + (begin + (local base https://api.telegram.org/) + (local bot (concat base bot-id)) + (local url (concat bot :/ :sendMessage)) + (local chat-id (lookup:uw :chat r)) + (local thread-id (lookup:uw :thread r)) + (local (pp k v) (concat k := v)) + (local msg (unwords mess)) + (eval + `(run:proc:attached + curl -X POST ,url + -d ,(pp :chat_id chat-id) + ,@(if thread-id (-d . ,(pp :message_thread_id thread-id))) + -d ,(pp :text msg) + )) + ) +) + + + diff --git a/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs b/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs index 2c21b219..5a10412e 100644 --- a/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs +++ b/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs @@ -687,7 +687,11 @@ eval' dict0 syn' = handle (handleForm syn') $ do ListVal [ SymbolVal "eval", e ] -> eval e >>= eval - ListVal [ SymbolVal "import", StringLike fn ] -> do + ListVal [ SymbolVal "import", e ] -> do + + fn <- eval e >>= \case + StringLike x -> pure x + _ -> throwIO (BadFormException @c syn') let importsName = "*runtime-imports*" let alreadyError = RuntimeError $ mkForm "runtime-error" [ mkStr @c ["already imported", pretty fn] ]