Skip to content
Permalink
Browse files

Fixing trade issue with integer

  • Loading branch information...
Depado committed Feb 15, 2016
1 parent c2c49f7 commit f3dd7d426ff65e362b725f61ccb1b06d43c6cda4
Showing with 5 additions and 5 deletions.
  1. +3 −3 plugins/trade/command.go
  2. +2 −2 plugins/trade/options.go
@@ -32,7 +32,7 @@ func (c *Command) Help(ib *irc.Connection, from string) {
return
}
ib.Privmsg(from, "Displays current crypto-currency trade market")
ib.Privmsg(from, "Usage : !trade [ammount] <from> <to> [--market=all|market_name] [--nomarket] [--sort=price|volume]")
ib.Privmsg(from, "Usage : !trade [ammount] <from> <to> [--market=all|market_name] [--sort=price|volume]")
}

// Get is the actual call to your plugin.
@@ -57,9 +57,9 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
return
}
if opt.Ammount == 1 {
ib.Privmsgf(to, "%v %s = %f %s", opt.Ammount, trade.Ticker.Base, float64(opt.Ammount)*rate, trade.Ticker.Target)
ib.Privmsgf(to, "%v %s = %f %s", opt.Ammount, trade.Ticker.Base, opt.Ammount*rate, trade.Ticker.Target)
} else {
ib.Privmsgf(to, "%v %s = %f %s (1 %s = %f %s)", opt.Ammount, trade.Ticker.Base, float64(opt.Ammount)*rate, trade.Ticker.Target, trade.Ticker.Base, rate, trade.Ticker.Target)
ib.Privmsgf(to, "%v %s = %f %s (1 %s = %f %s)", opt.Ammount, trade.Ticker.Base, opt.Ammount*rate, trade.Ticker.Target, trade.Ticker.Base, rate, trade.Ticker.Target)
}
if opt.Market != "" {
if opt.Market == "all" {
@@ -11,7 +11,7 @@ type options struct {
VolumeSort bool
Source string
Dest string
Ammount int
Ammount float64

This comment has been minimized.

Copy link
@nado

nado Feb 18, 2016

Contributor

Amount takes only one “m” :D

This comment has been minimized.

Copy link
@Depado

Depado Feb 18, 2016

Author Owner

Ffff...

Market string
}

@@ -35,7 +35,7 @@ func parseOptions(args []string) (options, error) {
}
}
if len(c) == 3 {
if opt.Ammount, err = strconv.Atoi(args[0]); err != nil {
if opt.Ammount, err = strconv.ParseFloat(args[0], 64); err != nil {
return opt, fmt.Errorf("Wrong value of first argument : %v not a number.", c[0])
}
opt.Source = c[1]

0 comments on commit f3dd7d4

Please sign in to comment.
You can’t perform that action at this time.