tg: Minor corrections to the godoc text

This commit is contained in:
Hamcha 2016-02-19 11:25:38 +00:00
parent 883dcc4483
commit 370ce1c1d8
3 changed files with 13 additions and 13 deletions

View file

@ -34,8 +34,8 @@ func (b *Broker) Close() {
b.Socket.Close()
}
// SendTextMessage sends a HTML-styles text message to a specific chat
// A reply_to message ID can be specified as optional parameter
// SendTextMessage sends a HTML-styles text message to a specific chat.
// A reply_to message ID can be specified as optional parameter.
func (b *Broker) SendTextMessage(chat *APIChat, text string, original *int) {
cmd := ClientCommand{
Type: CmdSendTextMessage,
@ -53,16 +53,16 @@ func (b *Broker) SendTextMessage(chat *APIChat, text string, original *int) {
fmt.Fprintln(b.Socket, string(data))
}
// GetFile sends a file retrieval request to the Broker
// This function is asynchronous as data will be delivered to the given callback
// GetFile sends a file retrieval request to the Broker.
// This function is asynchronous as data will be delivered to the given callback.
func (b *Broker) GetFile(fileID string, fn BrokerCallback) int {
cid := b.RegisterCallback(fn)
// Make file request
return cid
}
// RegisterCallback assigns a callback ID to the given callback and puts it on the callback list
// This function should never be called by clients
// RegisterCallback assigns a callback ID to the given callback and puts it on the callback list.
// This function should never be called by clients.
func (b *Broker) RegisterCallback(fn BrokerCallback) int {
cblen := len(b.Callbacks)
// List is full, append to end
@ -84,8 +84,8 @@ func (b *Broker) RegisterCallback(fn BrokerCallback) int {
return id
}
// RemoveCallback removes a callback from the callback list by ID
// This function should never be called by clients
// RemoveCallback removes a callback from the callback list by ID.
// This function should never be called by clients.
func (b *Broker) RemoveCallback(id int) {
b.Callbacks[id] = nil
if id < b.cbFree {
@ -94,8 +94,8 @@ func (b *Broker) RemoveCallback(id int) {
b.resizeCbArray()
}
// SpliceCallback retrieves a callback by ID and removes it from the list
// This function should never be called by clients
// SpliceCallback retrieves a callback by ID and removes it from the list.
// This function should never be called by clients.
func (b *Broker) SpliceCallback(id int) BrokerCallback {
defer b.RemoveCallback(id)
return b.Callbacks[id]

View file

@ -13,8 +13,8 @@ type UpdateHandler func(broker *Broker, message APIMessage)
// BrokerCallback is a callback for broker responses to client requests
type BrokerCallback func(broker *Broker, update BrokerUpdate)
// 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
// 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.
func CreateBrokerClient(brokerAddr string, updateFn UpdateHandler) error {
broker, err := ConnectToBroker(brokerAddr)
if err != nil {

View file

@ -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.
// If it finds a greeting message it will greet back the user (using the reply_to parameter)