Skip to content

Instantly share code, notes, and snippets.

@Cibernomadas
Created May 20, 2018 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cibernomadas/c4448b12d365315068daf941741d8222 to your computer and use it in GitHub Desktop.
Save Cibernomadas/c4448b12d365315068daf941741d8222 to your computer and use it in GitHub Desktop.
if decimal {
switch cmd {
case "suma":
txt = fmt.Sprintf("%f", af+bf)
case "resta":
txt = fmt.Sprintf("%f", af-bf)
case "multi":
txt = fmt.Sprintf("%f", af*bf)
case "div":
if bf == 0 {
txt = "No es posible dividir un número por cero"
} else {
txt = fmt.Sprintf("%f", af/bf)
}
}
} else {
switch cmd {
case "suma":
txt = fmt.Sprintf("%d", a+b)
case "resta":
txt = fmt.Sprintf("%d", a-b)
case "multi":
txt = fmt.Sprintf("%d", a*b)
case "div":
if b == 0 {
txt = "No es posible dividir un número por cero"
} else {
txt = fmt.Sprintf("%d", a/b)
}
}
}
enviarMensaje(bot, update.Message.Chat.ID, update.Message.MessageID, txt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment