refactor: move functions
This commit is contained in:
parent
658a041ff8
commit
522d253410
5 changed files with 163 additions and 147 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.gensokyo.cafe/kkyy/mycurrencynet"
|
||||
"github.com/dustin/go-humanize"
|
||||
|
|
@ -13,6 +14,25 @@ import (
|
|||
tele "gopkg.in/telebot.v3"
|
||||
)
|
||||
|
||||
var exchangeRates = mycurrencynet.New()
|
||||
|
||||
func initExchangeRates() {
|
||||
if err := exchangeRates.Update(); err != nil {
|
||||
logger.Panicw("Failed to update exchange rates", "err", err)
|
||||
}
|
||||
logger.Info("Exchange rates updated")
|
||||
|
||||
go exchangeRates.UpdateEvery(
|
||||
time.Hour,
|
||||
func(err error) {
|
||||
logger.Errorw("Failed to update exchange rates", "err", err)
|
||||
},
|
||||
func() {
|
||||
logger.Info("Exchange rates updated")
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func handleExchangeRateCmd(c tele.Context) error {
|
||||
msg := c.Message()
|
||||
if msg == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue