mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 15:10:59 +00:00
Split up common.go, file path fixes and much more
This commit is contained in:
@@ -2,10 +2,10 @@ package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/assets"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
|
||||
)
|
||||
@@ -112,7 +112,7 @@ func (b *Base) GetTicker(exchangeName string) string {
|
||||
tickerPrices[i].PriceATH,
|
||||
tickerPrices[i].Volume))
|
||||
}
|
||||
return common.JoinStrings(packagedTickers, "\n")
|
||||
return strings.Join(packagedTickers, "\n")
|
||||
}
|
||||
|
||||
// GetOrderbook returns staged orderbook data
|
||||
@@ -142,7 +142,7 @@ func (b *Base) GetOrderbook(exchangeName string) string {
|
||||
orderbooks[i].TotalAsks,
|
||||
orderbooks[i].TotalBids))
|
||||
}
|
||||
return common.JoinStrings(packagedOrderbooks, "\n")
|
||||
return strings.Join(packagedOrderbooks, "\n")
|
||||
}
|
||||
|
||||
// GetPortfolio returns staged portfolio info
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -364,24 +365,24 @@ func (s *Slack) HandleMessage(msg *Message) error {
|
||||
return errors.New("msg is nil")
|
||||
}
|
||||
|
||||
msg.Text = common.StringToLower(msg.Text)
|
||||
msg.Text = strings.ToLower(msg.Text)
|
||||
switch {
|
||||
case common.StringContains(msg.Text, cmdStatus):
|
||||
case strings.Contains(msg.Text, cmdStatus):
|
||||
return s.WebsocketSend("message", s.GetStatus())
|
||||
|
||||
case common.StringContains(msg.Text, cmdHelp):
|
||||
case strings.Contains(msg.Text, cmdHelp):
|
||||
return s.WebsocketSend("message", getHelp)
|
||||
|
||||
case common.StringContains(msg.Text, cmdTicker):
|
||||
case strings.Contains(msg.Text, cmdTicker):
|
||||
return s.WebsocketSend("message", s.GetTicker("ANX"))
|
||||
|
||||
case common.StringContains(msg.Text, cmdOrderbook):
|
||||
case strings.Contains(msg.Text, cmdOrderbook):
|
||||
return s.WebsocketSend("message", s.GetOrderbook("ANX"))
|
||||
|
||||
case common.StringContains(msg.Text, cmdSettings):
|
||||
case strings.Contains(msg.Text, cmdSettings):
|
||||
return s.WebsocketSend("message", s.GetSettings())
|
||||
|
||||
case common.StringContains(msg.Text, cmdPortfolio):
|
||||
case strings.Contains(msg.Text, cmdPortfolio):
|
||||
return s.WebsocketSend("message", s.GetPortfolio())
|
||||
|
||||
default:
|
||||
|
||||
@@ -89,7 +89,7 @@ func (s *SMSGlobal) GetContactByNumber(number string) (Contact, error) {
|
||||
// GetContactByName returns a contact with supplied name
|
||||
func (s *SMSGlobal) GetContactByName(name string) (Contact, error) {
|
||||
for x := range s.Contacts {
|
||||
if common.StringToLower(s.Contacts[x].Name) == common.StringToLower(name) {
|
||||
if strings.ToLower(s.Contacts[x].Name) == strings.ToLower(name) {
|
||||
return s.Contacts[x], nil
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ func (s *SMSGlobal) AddContact(contact Contact) error {
|
||||
// ContactExists checks to see if a contact exists
|
||||
func (s *SMSGlobal) ContactExists(contact Contact) bool {
|
||||
for x := range s.Contacts {
|
||||
if s.Contacts[x].Number == contact.Number && common.StringToLower(s.Contacts[x].Name) == common.StringToLower(contact.Name) {
|
||||
if s.Contacts[x].Number == contact.Number && strings.ToLower(s.Contacts[x].Name) == strings.ToLower(contact.Name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func (s *SMSGlobal) SendMessage(to, message string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !common.StringContains(resp, "OK: 0; Sent queued message") {
|
||||
if !strings.Contains(resp, "OK: 0; Sent queued message") {
|
||||
return errSMSNotSent
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/communications/base"
|
||||
@@ -56,7 +57,7 @@ func (s *SMTPservice) Send(subject, alert string) error {
|
||||
return errors.New("STMPservice Send() please add subject and alert")
|
||||
}
|
||||
|
||||
list := common.SplitStrings(s.RecipientList, ",")
|
||||
list := strings.Split(s.RecipientList, ",")
|
||||
|
||||
for i := range list {
|
||||
messageToSend := fmt.Sprintf(
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/communications/base"
|
||||
@@ -139,25 +140,25 @@ func (t *Telegram) InitialConnect() {
|
||||
// HandleMessages handles incoming message from the long polling routine
|
||||
func (t *Telegram) HandleMessages(text string, chatID int64) error {
|
||||
switch {
|
||||
case common.StringContains(text, cmdHelp):
|
||||
case strings.Contains(text, cmdHelp):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, cmdHelpReply), chatID)
|
||||
|
||||
case common.StringContains(text, cmdStart):
|
||||
case strings.Contains(text, cmdStart):
|
||||
return t.SendMessage(fmt.Sprintf("%s: START COMMANDS HERE", talkRoot), chatID)
|
||||
|
||||
case common.StringContains(text, cmdOrders):
|
||||
case strings.Contains(text, cmdOrders):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, t.GetOrderbook("ANX")), chatID)
|
||||
|
||||
case common.StringContains(text, cmdStatus):
|
||||
case strings.Contains(text, cmdStatus):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, t.GetStatus()), chatID)
|
||||
|
||||
case common.StringContains(text, cmdTicker):
|
||||
case strings.Contains(text, cmdTicker):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, t.GetTicker("ANX")), chatID)
|
||||
|
||||
case common.StringContains(text, cmdSettings):
|
||||
case strings.Contains(text, cmdSettings):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, t.GetSettings()), chatID)
|
||||
|
||||
case common.StringContains(text, cmdPortfolio):
|
||||
case strings.Contains(text, cmdPortfolio):
|
||||
return t.SendMessage(fmt.Sprintf("%s: %s", talkRoot, t.GetPortfolio()), chatID)
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user