Exemplo n.º 1
0
func calculate(line *base.Line) {
	maths := line.Args[1]
	if num, err := calc.Calc(maths); err == nil {
		bot.ReplyN(line, "%s = %g", maths, num)
	} else {
		bot.ReplyN(line, "%s error while parsing %s", err, maths)
	}
}
Exemplo n.º 2
0
func calculate(ctx *bot.Context) {
	nick := strings.ToLower(ctx.Nick)
	maths := ctx.Text()
	tm := calc.TokenMap{}
	if res, ok := results[nick]; ok {
		tm["result"] = res
	}
	if num, err := calc.Calc(maths, tm); err == nil {
		ctx.ReplyN("%s = %g", maths, num)
		tm[nick] = num
	} else {
		ctx.ReplyN("%s error while parsing %s", err, maths)
	}
}