constant for timer

Former-commit-id: 14406e99e5ae4b118aaec55be6375d83aa47f73f
botanswer
AnisB 3 years ago
parent b988fb5a19
commit dc33b49fd8

@ -1 +0,0 @@
ccfbe1adb71858c6f07073d72fd686b90ef95dbb

@ -28,7 +28,7 @@ const (
// APIEndpoint = "https://hodlhodl.com/api/v1"
//TestAPIEndpoint = "https://hhtestnet.com/api/v1"
//APIkey = "***REMOVED***"
JobSchedulerInterval = 60 * time.Second
HodlHodlCheckTimer = 5 * time.Second
// Config
infoFormat = "====== "
@ -97,7 +97,6 @@ type HelloCmd struct {
}
type HelpCmd struct {
}
func (*DefaultCmd) Run(args []string) (string, error) {
@ -117,7 +116,6 @@ func (*HelpCmd) Help(args []string) (string, error) {
return "this is help of help", nil
}
func (*HelloCmd) Run(args []string) (string, error) {
/*for _, result := range args {
if result == "help" {
@ -133,13 +131,13 @@ func (*HelloCmd) Help(args []string) (string, error) {
}
func handleCommand(command Command, args []string) string {
if len(args) != 0 && args[0] == "help" {
fmt.Println("Inside 1")
result, err := command.Help(args)
if err != nil {
return "error"
}
}
return result
} else if len(args) != 0 && args[0] != "help" {
return "Unkown command"
@ -223,15 +221,16 @@ func startClient(config *config) {
fmt.Println("Client is running")
}
timer := time.NewTicker(5 * time.Second)
timer := time.NewTicker(HodlHodlCheckTimer)
notifications := make(chan string, 100)
go hodlNotifications(client, config, notifications)
fmt.Println("checking notifs every ", HodlHodlCheckTimer)
for {
select {
case <-timer.C:
fmt.Println("checking notifs...")
//fmt.Println("checking notifs...")
notifications <- gethdlNotif(config.Hodlhodl[APIKey], config.Hodlhodl[APIEndPoint])
}
}
@ -245,7 +244,7 @@ func answerMessage(s xmpp.Sender, p stanza.Packet) {
return
}
_, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From)
//answersArray := []string{"Test", "Help", "Time"}
if len(msg.Body) > 0 {
fmt.Println("keep the message", msg.Body)
@ -262,7 +261,7 @@ func answerMessage(s xmpp.Sender, p stanza.Packet) {
for regCommandName, regCommand := range Commands {
var result string
if receivedCmd == "#" + regCommandName {
if receivedCmd == "/"+regCommandName {
result = handleCommand(regCommand, args)
} /*else {
result = handleCommand(Commands["default"], args)
@ -272,7 +271,7 @@ func answerMessage(s xmpp.Sender, p stanza.Packet) {
s.Send(reply)
}
}
//switch {
//case strings.Contains(strings.ToLower(msg.Body), "test"):
//answer := "succesful test"

Loading…
Cancel
Save