about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorlogin <login@tilde.team>2021-12-12 13:40:13 +0000
committerlogin <login@tilde.team>2021-12-12 13:40:13 +0000
commitc0d17610538b41a13401aac6c83f4a6e452f29dd (patch)
treefd98ecb630f79201313367989a228fb792755d79
parent337ce90729d3a8d99af5abb02143ab9c67ff74bb (diff)
downloadtcoin-c0d17610538b41a13401aac6c83f4a6e452f29dd.tar.gz
made changes to be compatible with minerbot's new "username" format vs. the old "~username" format
Made this change so that new "!minercoin ask" awarded minercoins will still show up in tcoin without losing old !minercoins awarded.

In other words, the inflation will continue until morale improves.
-rw-r--r--pcoin.cpp16
-rw-r--r--tcoin.cpp15
2 files changed, 29 insertions, 2 deletions
diff --git a/pcoin.cpp b/pcoin.cpp
index bde5416..3038f8a 100644
--- a/pcoin.cpp
+++ b/pcoin.cpp
@@ -50,6 +50,7 @@
 #endif
 #ifndef MINERCOIN_OFF
   #define MINERCOIN_CMD_PRE_USERNAME "/bin/grep -oP '(?<=\"~"
+  #define MINERCOIN_CMD_PRE_USERNAME2 "/bin/grep -oP '(?<=\""
   #define MINERCOIN_CMD_POST_USERNAME "\": )[[:digit:]]+' /home/minerobber/Code/minerbot/minercoin.json"
 #endif
 #define USERNAME_LENGTH_LIMIT 25
@@ -1864,7 +1865,7 @@ int main(int argc, char *argv[])
   #endif
 
   #ifndef MINERCOIN_OFF
-  //adding minercoin scores from minerobber to base amount
+  //adding minercoin scores from minerobber to base amount (from "~username" in minerbot)
   {
     std::string command_to_exec = std::string(MINERCOIN_CMD_PRE_USERNAME) + get_username() + std::string(MINERCOIN_CMD_POST_USERNAME);
     std::string number_of_tildes = exec(command_to_exec.c_str());
@@ -1876,6 +1877,19 @@ int main(int argc, char *argv[])
       //multiplied by 100 to convert tildecoins to centitildecoins, which
       //is the unit used throughout the program (and converted appropriately when displayed)
   }
+
+  //adding minercoin scores from minerobber to base amount (from "username" in minerbot)
+  {
+    std::string command_to_exec = std::string(MINERCOIN_CMD_PRE_USERNAME2) + get_username() + std::string(MINERCOIN_CMD_POST_USERNAME);
+    std::string number_of_tildes = exec(command_to_exec.c_str());
+    number_of_tildes.pop_back();
+    //to get rid of the newline at the end
+    if(is_number(number_of_tildes.c_str()))
+      minercoin_amount += strtol100(number_of_tildes.c_str());
+      base_amount += minercoin_amount;
+      //multiplied by 100 to convert tildecoins to centitildecoins, which
+      //is the unit used throughout the program (and converted appropriately when displayed)
+  }
   #endif
 
   user_amount = get_file_value(get_username().c_str());
diff --git a/tcoin.cpp b/tcoin.cpp
index 4e51d7e..a569b16 100644
--- a/tcoin.cpp
+++ b/tcoin.cpp
@@ -49,6 +49,7 @@
 #endif
 #ifndef MINERCOIN_OFF
   #define MINERCOIN_CMD_PRE_USERNAME "/bin/grep -oP '(?<=\"~"
+  #define MINERCOIN_CMD_PRE_USERNAME2 "/bin/grep -oP '(?<=\""
   #define MINERCOIN_CMD_POST_USERNAME "\": )[[:digit:]]+' /home/minerobber/Code/minerbot/minercoin.json"
 #endif
 #define USERNAME_LENGTH_LIMIT 25
@@ -1686,7 +1687,7 @@ int main(int argc, char *argv[])
   #endif
 
   #ifndef MINERCOIN_OFF
-  //adding minercoin scores from minerobber to base amount
+  //adding minercoin scores from minerobber to base amount (from "~username" entry in minerbot)
   {
     std::string command_to_exec = std::string(MINERCOIN_CMD_PRE_USERNAME) + get_username() + std::string(MINERCOIN_CMD_POST_USERNAME);
     std::string number_of_tildes = exec(command_to_exec.c_str());
@@ -1698,6 +1699,18 @@ int main(int argc, char *argv[])
       //multiplied by 100 to convert tildecoins to centitildecoins, which
       //is the unit used throughout the program (and converted appropriately when displayed)
   }
+  //adding minercoin scores from minerobber to base amount (from "username" entry in minerbot)
+  {
+    std::string command_to_exec = std::string(MINERCOIN_CMD_PRE_USERNAME2) + get_username() + std::string(MINERCOIN_CMD_POST_USERNAME);
+    std::string number_of_tildes = exec(command_to_exec.c_str());
+    number_of_tildes.pop_back();
+    //to get rid of the newline at the end
+    if(is_number(number_of_tildes.c_str()))
+      minercoin_amount += strtol100(number_of_tildes.c_str());
+      base_amount += minercoin_amount;
+      //multiplied by 100 to convert tildecoins to centitildecoins, which
+      //is the unit used throughout the program (and converted appropriately when displayed)
+  }
   #endif
   srand((long int)(std::time(NULL)) + strtol_fast(exec(BIN_ECHO_CMD).c_str()));