mirror of https://github.com/voidlizard/hbs2
bf6 telegram bot example
This commit is contained in:
parent
69a827e266
commit
768a8181e7
|
@ -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)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -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] ]
|
||||
|
|
Loading…
Reference in New Issue