Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
- Locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kiryukhin committed Dec 20, 2018
1 parent 39777b1 commit 98399ba
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"
)

Expand All @@ -23,23 +22,19 @@ type API struct {
token string
baseUrl string
client Doer
mu *sync.Mutex
}

// NewAPI constructor of API object
func NewAPI(token string) *API {
return &API{
token: token,
baseUrl: "https://botapi.icq.net",
mu: new(sync.Mutex),
client: http.DefaultClient,
}
}

// SendMessage with `message` text to `to` participant
func (a *API) SendMessage(message Message) (*MessageResponse, error) {
a.mu.Lock()
defer a.mu.Unlock()
parse, _ := json.Marshal(message.Parse)
v := url.Values{}
v.Set("aimsid", a.token)
Expand All @@ -66,8 +61,6 @@ func (a *API) SendMessage(message Message) (*MessageResponse, error) {

// UploadFile to ICQ servers and returns URL to file
func (a *API) UploadFile(fileName string, r io.Reader) (*FileResponse, error) {
a.mu.Lock()
defer a.mu.Unlock()
v := url.Values{}
v.Set("aimsid", a.token)
v.Set("filename", fileName)
Expand Down

0 comments on commit 98399ba

Please sign in to comment.