This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues or pull requests.
2016-02-19 11:25:38 +00:00
|
|
|
package tg_test
|
2016-02-19 11:20:13 +00:00
|
|
|
|
2016-02-19 11:28:17 +00:00
|
|
|
// This example creates a basic client that connects to a broker and checks for message containing greetings.
|
2016-02-19 11:20:13 +00:00
|
|
|
// If it finds a greeting message it will greet back the user (using the reply_to parameter)
|
2016-02-19 11:27:06 +00:00
|
|
|
func ExampleCreateBrokerClient() {
|
2016-02-19 11:20:13 +00:00
|
|
|
CreateBrokerClient("localhost:7314", func(broker *Broker, message APIMessage) {
|
|
|
|
// Check if it's a text message
|
|
|
|
if message.Text != nil {
|
|
|
|
// Check that it's a greeting
|
|
|
|
if *(message.Text) == "hello" || *(message.Text) == "hi" {
|
|
|
|
// Reply with a greeting!
|
|
|
|
broker.SendTextMessage(message.Chat, "Hello!", message.MessageID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|