|
@@ -10,6 +10,7 @@ import (
|
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
|
|
|
|
|
ethmineapi "GoEthemineTelegramBot/ethermineapi"
|
|
|
+ "GoEthemineTelegramBot/botsettings"
|
|
|
)
|
|
|
|
|
|
func (c *Connection) AddUser(reqChat *tgbotapi.Chat) (string, error) {
|
|
@@ -265,7 +266,7 @@ func (c *Connection) GetLastPayout(chatId int64) string {
|
|
|
Find(&dbPayoutRecords)
|
|
|
//Line 560 of Program.cs
|
|
|
if len(dbPayoutRecords) == 0 {
|
|
|
- url := fmt.Sprintf("%s/miner/%s/payouts", appSettings.ApiUrl, wallet)
|
|
|
+ url := fmt.Sprintf("%s/miner/%s/payouts", botsettings.ApiUrl(), wallet)
|
|
|
var payouts ethmineapi.JsonPayouts
|
|
|
err := ethmineapi.UnmasrshalFromUrl(url, &payouts)
|
|
|
if err != nil {
|
|
@@ -275,7 +276,7 @@ func (c *Connection) GetLastPayout(chatId int64) string {
|
|
|
lastPayout := payouts.Data[0]
|
|
|
|
|
|
message := fmt.Sprintf("Payout date: %s\n", time.Unix(lastPayout.PaidOn, 0).Format("Monday, January 2, 2006 3:04 PM"))
|
|
|
- message += fmt.Sprintf("Amount: %.5f %s\n", float64(lastPayout.Amount)/math.Pow10(18), appSettings.Currency)
|
|
|
+ message += fmt.Sprintf("Amount: %.5f %s\n", float64(lastPayout.Amount)/math.Pow10(18), botsettings.Currency())
|
|
|
message += "Data source: Ethermine API \n"
|
|
|
|
|
|
return message
|
|
@@ -290,10 +291,10 @@ func (c *Connection) GetLastPayout(chatId int64) string {
|
|
|
message += fmt.Sprintf("Amount: %.5f ETH\n", float64(dbPayoutRecords[0].Amount)/math.Pow10(18))
|
|
|
|
|
|
for _, payoutRecord := range dbPayoutRecords {
|
|
|
- message += fmt.Sprintf("Worker %s paid: %.5f %s\n", //TODO ETH = AppSettings.currency
|
|
|
+ message += fmt.Sprintf("Worker %s paid: %.5f %s\n",
|
|
|
payoutRecord.Worker,
|
|
|
float64(payoutRecord.Amount)/math.Pow10(18),
|
|
|
- appSettings.Currency)
|
|
|
+ botsettings.Currency())
|
|
|
}
|
|
|
|
|
|
message += "Data source: Bot database \n"
|
|
@@ -304,11 +305,11 @@ func (c *Connection) GetLastPayout(chatId int64) string {
|
|
|
|
|
|
|
|
|
func GetActualRate() string {
|
|
|
- url := fmt.Sprintf("%s/networkStats", appSettings.ApiUrl)
|
|
|
+ url := fmt.Sprintf("%s/networkStats", botsettings.ApiUrl())
|
|
|
var networkStats ethmineapi.JsonNetworkStats
|
|
|
err := ethmineapi.UnmasrshalFromUrl(url, &networkStats)
|
|
|
if err != nil {
|
|
|
- return fmt.Sprintf("Error with getting data from %s", appSettings.ApiUrl)
|
|
|
+ return fmt.Sprintf("Error with getting data from %s", botsettings.ApiUrl())
|
|
|
}
|
|
|
data := networkStats.Data
|
|
|
actualRate := fmt.Sprintf("ETH: %.2f\nBTC: %.2f", data.Usd, float64(data.Usd)/float64(data.Btc))
|
|
@@ -316,7 +317,7 @@ func GetActualRate() string {
|
|
|
}
|
|
|
|
|
|
func GetActualData(miner string) string {
|
|
|
- url := fmt.Sprintf("%s/miner/%s/currentStats", appSettings.ApiUrl, miner)
|
|
|
+ url := fmt.Sprintf("%s/miner/%s/currentStats", botsettings.ApiUrl(), miner)
|
|
|
var currentStats ethmineapi.JsonCurrentStats
|
|
|
err := ethmineapi.UnmasrshalFromUrl(url, ¤tStats)
|
|
|
if err != nil {
|