|
@@ -67,6 +67,8 @@ namespace EthermineBotTelegram
|
|
|
|
|
|
Console.WriteLine(("Scheduler started!"));
|
|
|
|
|
|
+ Thread.Sleep(5000);
|
|
|
+
|
|
|
botClient.OnMessage += BotOnMessage;
|
|
|
botClient.StartReceiving();
|
|
|
|
|
@@ -127,11 +129,7 @@ namespace EthermineBotTelegram
|
|
|
case "/help":
|
|
|
//await SendHelp();
|
|
|
break;
|
|
|
-
|
|
|
- case "/gas":
|
|
|
- await SendCalcTime(e);
|
|
|
- break;
|
|
|
-
|
|
|
+
|
|
|
default:
|
|
|
//await Usage(message);
|
|
|
if (e.Message.Chat.Id > 0)
|
|
@@ -165,7 +163,7 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
await botClient.SendTextMessageAsync(
|
|
|
chatId: e.Message.Chat,
|
|
|
text: "An exception occurred while executing this command.");
|
|
@@ -186,8 +184,9 @@ namespace EthermineBotTelegram
|
|
|
if (lastMinerRecord != null)
|
|
|
{
|
|
|
//var lastWorkerRecord = new workers();
|
|
|
- var lastTime = Botdb.workers.Where(w => w.wallet == wallet)
|
|
|
+ long lastTime = Botdb.workers.Where(w => w.wallet == wallet)
|
|
|
.Max(w => w.time);
|
|
|
+
|
|
|
var lastWorkerRecord = Botdb.workers.Where(w => w.wallet == wallet && w.time == lastTime)
|
|
|
.OrderByDescending(w => w.time).ToList();
|
|
|
|
|
@@ -233,9 +232,8 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (HttpRequestException exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -261,7 +259,7 @@ namespace EthermineBotTelegram
|
|
|
//}
|
|
|
//catch (Exception exception)
|
|
|
//{
|
|
|
- // await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ // await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
// await botClient.SendTextMessageAsync(
|
|
|
// chatId: e,
|
|
|
// text: "Something got wrong! Check entered wallet or try later.");
|
|
@@ -311,7 +309,7 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -356,7 +354,7 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
await botClient.SendTextMessageAsync(
|
|
|
chatId: e.Message.Chat,
|
|
|
text: "An exception occurred while executing this command.");
|
|
@@ -395,7 +393,7 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
await botClient.SendTextMessageAsync(
|
|
|
chatId: e,
|
|
|
text: "An exception occurred while executing this command.");
|
|
@@ -404,19 +402,19 @@ namespace EthermineBotTelegram
|
|
|
|
|
|
public static async Task UpdateData()
|
|
|
{
|
|
|
- var usersList = Botdb.users.Where(u=>u.wallet != null).ToList();
|
|
|
- foreach (users u in usersList)
|
|
|
+ var walletList = Botdb.users.Where(u=>u.wallet != null).Select(u=> u.wallet).Distinct().ToList();
|
|
|
+ foreach (string wallet in walletList)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var url = AppSettings.poolApiUrl + "/miner/" + u.wallet + "/currentStats";
|
|
|
+ var url = AppSettings.poolApiUrl + "/miner/" + wallet + "/currentStats";
|
|
|
var currnentStats = JsonDownloader._download_serialized_json_data<JsonCurrentStats>(url);
|
|
|
|
|
|
if (currnentStats.status == "OK")
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync($"Create new record for {u.wallet}");
|
|
|
+ await Console.Out.WriteLineAsync($"Create new record for {wallet}");
|
|
|
miners newMinerRecord = new miners();
|
|
|
- newMinerRecord.wallet = u.wallet;
|
|
|
+ newMinerRecord.wallet = wallet;
|
|
|
newMinerRecord.time = currnentStats.data.time;
|
|
|
newMinerRecord.reported_hashrate = currnentStats.data.reportedHashrate;
|
|
|
newMinerRecord.current_hashrate = currnentStats.data.currentHashrate;
|
|
@@ -437,7 +435,7 @@ namespace EthermineBotTelegram
|
|
|
//await Botdb.SaveChangesAsync();
|
|
|
await Console.Out.WriteLineAsync($"Added new row for {newMinerRecord.wallet}");
|
|
|
|
|
|
- if (newMinerRecord.unpaid < lastMinerRecord.unpaid)
|
|
|
+ if (lastMinerRecord != null && newMinerRecord.unpaid < lastMinerRecord.unpaid)
|
|
|
{
|
|
|
await botClient.SendTextMessageAsync(
|
|
|
chatId: Botdb.users.Where(user => user.wallet == newMinerRecord.wallet)
|
|
@@ -445,7 +443,7 @@ namespace EthermineBotTelegram
|
|
|
text: "Payout detected!");
|
|
|
}
|
|
|
|
|
|
- url = AppSettings.poolApiUrl + "/miner/" + u.wallet + "/workers";
|
|
|
+ url = AppSettings.poolApiUrl + "/miner/" + wallet + "/workers";
|
|
|
var currentWorker = JsonDownloader._download_serialized_json_data<JsonWorker>(url);
|
|
|
|
|
|
if (currentWorker.status == "OK")
|
|
@@ -478,13 +476,13 @@ namespace EthermineBotTelegram
|
|
|
//check for payout
|
|
|
if (newMinerRecord.unpaid < lastMinerRecord.unpaid)
|
|
|
{
|
|
|
- url = AppSettings.poolApiUrl + "/miner/" + u.wallet + "/payouts";
|
|
|
+ url = AppSettings.poolApiUrl + "/miner/" + wallet + "/payouts";
|
|
|
var payouts = JsonDownloader._download_serialized_json_data<JsonPayouts>(url);
|
|
|
|
|
|
await Console.Out.WriteLineAsync($"Last payout time = {DateTimeOffset.FromUnixTimeSeconds(payouts.data[0].paidOn).LocalDateTime.ToString("f")}");
|
|
|
|
|
|
var newPayoutRecord = new payouts();
|
|
|
- newPayoutRecord.wallet = u.wallet;
|
|
|
+ newPayoutRecord.wallet = wallet;
|
|
|
newPayoutRecord.time = payouts.data[0].paidOn;
|
|
|
newPayoutRecord.amount = payouts.data[0].amount;
|
|
|
newPayoutRecord.worker = newWorkerRecord.worker;
|
|
@@ -540,7 +538,6 @@ namespace EthermineBotTelegram
|
|
|
else
|
|
|
{
|
|
|
Botdb.workers.Add(newWorkerRecord);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -557,28 +554,19 @@ namespace EthermineBotTelegram
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync($"Error response from pool for {u.wallet}!");
|
|
|
+ await Console.Out.WriteLineAsync($"Error response from pool for {wallet}!");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
- await Console.Out.WriteLineAsync(exception.Message);
|
|
|
+ await Console.Out.WriteLineAsync(exception.Message + " " + exception.StackTrace + " " + exception.StackTrace);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- static async Task SendCalcTime(MessageEventArgs e)
|
|
|
- {
|
|
|
- var url = "https://api.etherscan.io/api?module=gastracker&action=gasestimate&gasprice=" + e.Message.Text.Split(' ')[1] + "000000000";
|
|
|
- var etherscanGas = JsonDownloader._download_serialized_json_data<JsonEtherscanGas>(url);
|
|
|
- await botClient.SendTextMessageAsync(
|
|
|
- chatId: e.Message.Chat,
|
|
|
- text: $"Estimated Confirmation Duration: {etherscanGas.result} seconds");
|
|
|
- }
|
|
|
}
|
|
|
}
|