Fix example
This commit is contained in:
parent
10ef1429c3
commit
487ffb1bf7
1 changed files with 8 additions and 4 deletions
|
@ -1,15 +1,19 @@
|
||||||
package tg_test
|
package tg_test
|
||||||
|
|
||||||
|
import "git.fromouter.space/hamcha/tg"
|
||||||
|
|
||||||
// This example creates a basic client that connects to a broker and checks for message containing greetings.
|
// This example creates a basic client that connects to a broker and checks for message containing greetings.
|
||||||
// If it finds a greeting message it will greet back the user (using the reply_to parameter)
|
// If it finds a greeting message it will greet back the user (using the reply_to parameter)
|
||||||
func ExampleCreateBrokerClient() {
|
func ExampleCreateBrokerClient() {
|
||||||
CreateBrokerClient("localhost:7314", func(broker *Broker, message APIMessage) {
|
tg.CreateBrokerClient("localhost:7314", func(broker *tg.Broker, update tg.APIUpdate) {
|
||||||
// Check if it's a text message
|
// Check if it's a text message
|
||||||
if message.Text != nil {
|
if update.Message != nil && update.Message.Text != nil {
|
||||||
// Check that it's a greeting
|
// Check that it's a greeting
|
||||||
if *(message.Text) == "hello" || *(message.Text) == "hi" {
|
if *(update.Message.Text) == "hello" || *(update.Message.Text) == "hi" {
|
||||||
// Reply with a greeting!
|
// Reply with a greeting!
|
||||||
broker.SendTextMessage(message.Chat, "Hello!", message.MessageID)
|
broker.SendTextMessage(update.Message.Chat, "Hello!", &tg.MessageOptions{
|
||||||
|
ReplyID: &update.Message.MessageID,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue