Skip to content

Commit

Permalink
Add answerCallbackQuery Readme.md doc
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsonfi committed May 10, 2017
1 parent 6df6745 commit 99da462
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ There is also a template which you can use to bootstrap your project:
export TELEGRAM_TOKEN=...
lein run

## Detecting user's actions
## Detecting user's actions

Telegram sends updates about events in chats in form of
[Update](https://core.telegram.org/bots/api#update) objects.

Inside those there could be commands, inline queries and many more.
Inside those there could be commands, inline queries and many more.
To help you with these Morse provides you helpers and some macros in
`morse.handlers` namespace.

Expand All @@ -38,7 +38,7 @@ you'll find similarities here:
(ns user
(:require [morse.handlers :as h]
[morse.api :as t]))

(def token "YOUR-BIG-SECRET")

; This will define bot-api function, which later could be
Expand All @@ -48,20 +48,20 @@ you'll find similarities here:
; This could be done in form of a function:
(h/command-fn "start" (fn [{{id :id :as chat} :chat}]
(println "Bot joined new chat: " chat)
(t/send-text token id "Welcome!")))
(t/send-text token id "Welcome!")))

; You can use short syntax for same purposes
; Destructuring works same way as in function above
(h/command "help" {{id :id :as chat} :chat}
(println "Help was requested in " chat)
(t/send-text token id "Help is on the way"))

; Handlers will be applied until there are any of those
; returns non-nil result processing update.
; Note that sending stuff to the user returns non-nil

; Note that sending stuff to the user returns non-nil
; response from Telegram API.

; So match-all catch-through case would look something like this:
(h/message message (println "Intercepted message:" message)))

Expand Down Expand Up @@ -101,7 +101,7 @@ in a similar form:
### Callbacks

You can provide handlers for [Callbacks](https://core.telegram.org/bots/api#answercallbackquery)
which are sent from [inline keyboards](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating)
which are sent from [inline keyboards](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating)

```clojure
(callback-fn (fn [data] (println "Received callback: " inline)))
Expand Down Expand Up @@ -251,6 +251,17 @@ Sends an answer to an inline query.
:gif_url "http://funnygifs/gif.gif"}])
```

### [`answerCallbackQuery`](https://core.telegram.org/bots/api#answercallbackquery)

Sends an answer to an callback query sent from inline keyboards.

```clojure
(api/answer-callback token
callback-query-id
text
show-alert)
```

## License

Copyright © 2016 Anton Chebotaev
Expand Down

0 comments on commit 99da462

Please sign in to comment.