tg: Minor corrections to the godoc text
This commit is contained in:
parent
883dcc4483
commit
370ce1c1d8
3 changed files with 13 additions and 13 deletions
20
tg/broker.go
20
tg/broker.go
|
@ -34,8 +34,8 @@ func (b *Broker) Close() {
|
||||||
b.Socket.Close()
|
b.Socket.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendTextMessage sends a HTML-styles text message to a specific chat
|
// SendTextMessage sends a HTML-styles text message to a specific chat.
|
||||||
// A reply_to message ID can be specified as optional parameter
|
// A reply_to message ID can be specified as optional parameter.
|
||||||
func (b *Broker) SendTextMessage(chat *APIChat, text string, original *int) {
|
func (b *Broker) SendTextMessage(chat *APIChat, text string, original *int) {
|
||||||
cmd := ClientCommand{
|
cmd := ClientCommand{
|
||||||
Type: CmdSendTextMessage,
|
Type: CmdSendTextMessage,
|
||||||
|
@ -53,16 +53,16 @@ func (b *Broker) SendTextMessage(chat *APIChat, text string, original *int) {
|
||||||
fmt.Fprintln(b.Socket, string(data))
|
fmt.Fprintln(b.Socket, string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFile sends a file retrieval request to the Broker
|
// GetFile sends a file retrieval request to the Broker.
|
||||||
// This function is asynchronous as data will be delivered to the given callback
|
// This function is asynchronous as data will be delivered to the given callback.
|
||||||
func (b *Broker) GetFile(fileID string, fn BrokerCallback) int {
|
func (b *Broker) GetFile(fileID string, fn BrokerCallback) int {
|
||||||
cid := b.RegisterCallback(fn)
|
cid := b.RegisterCallback(fn)
|
||||||
// Make file request
|
// Make file request
|
||||||
return cid
|
return cid
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterCallback assigns a callback ID to the given callback and puts it on the callback list
|
// RegisterCallback assigns a callback ID to the given callback and puts it on the callback list.
|
||||||
// This function should never be called by clients
|
// This function should never be called by clients.
|
||||||
func (b *Broker) RegisterCallback(fn BrokerCallback) int {
|
func (b *Broker) RegisterCallback(fn BrokerCallback) int {
|
||||||
cblen := len(b.Callbacks)
|
cblen := len(b.Callbacks)
|
||||||
// List is full, append to end
|
// List is full, append to end
|
||||||
|
@ -84,8 +84,8 @@ func (b *Broker) RegisterCallback(fn BrokerCallback) int {
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveCallback removes a callback from the callback list by ID
|
// RemoveCallback removes a callback from the callback list by ID.
|
||||||
// This function should never be called by clients
|
// This function should never be called by clients.
|
||||||
func (b *Broker) RemoveCallback(id int) {
|
func (b *Broker) RemoveCallback(id int) {
|
||||||
b.Callbacks[id] = nil
|
b.Callbacks[id] = nil
|
||||||
if id < b.cbFree {
|
if id < b.cbFree {
|
||||||
|
@ -94,8 +94,8 @@ func (b *Broker) RemoveCallback(id int) {
|
||||||
b.resizeCbArray()
|
b.resizeCbArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpliceCallback retrieves a callback by ID and removes it from the list
|
// SpliceCallback retrieves a callback by ID and removes it from the list.
|
||||||
// This function should never be called by clients
|
// This function should never be called by clients.
|
||||||
func (b *Broker) SpliceCallback(id int) BrokerCallback {
|
func (b *Broker) SpliceCallback(id int) BrokerCallback {
|
||||||
defer b.RemoveCallback(id)
|
defer b.RemoveCallback(id)
|
||||||
return b.Callbacks[id]
|
return b.Callbacks[id]
|
||||||
|
|
|
@ -13,8 +13,8 @@ type UpdateHandler func(broker *Broker, message APIMessage)
|
||||||
// BrokerCallback is a callback for broker responses to client requests
|
// BrokerCallback is a callback for broker responses to client requests
|
||||||
type BrokerCallback func(broker *Broker, update BrokerUpdate)
|
type BrokerCallback func(broker *Broker, update BrokerUpdate)
|
||||||
|
|
||||||
// CreateBrokerClient creates a connection to a broker and sends all webhook updates to a given function
|
// CreateBrokerClient creates a connection to a broker and sends all webhook updates to a given function.
|
||||||
// This is the intended way to create clients, please refer to examples for how to make a simple client
|
// This is the intended way to create clients, please refer to examples for how to make a simple client.
|
||||||
func CreateBrokerClient(brokerAddr string, updateFn UpdateHandler) error {
|
func CreateBrokerClient(brokerAddr string, updateFn UpdateHandler) error {
|
||||||
broker, err := ConnectToBroker(brokerAddr)
|
broker, err := ConnectToBroker(brokerAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package tg
|
package tg_test
|
||||||
|
|
||||||
// This function creates a basic client that connects to a broker and checks for message containing greetings.
|
// This function 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)
|
||||||
|
|
Reference in a new issue