当我有模式时,我正在通过电报历史记录(txt文件)逐行读取
Free_Trade_Calls__AltSignals:* / * (*)
例如
Free_Trade_Calls__AltSignals:GAS / BTC (binance)
然后在每个单独的变量中存储“跟随行”(并且还将该存储对RDN / BTC和交换bittrex存储在单独的变量中),直到它达到时间戳(今天的日期),然后再次搜索模式
但是当我看到模式
Free_Trade_Calls__AltSignals:TARGET
进入下一行
整个例子
Free_Trade_Calls__AltSignals:IOC/ BTC (bittrex)
BUY : 0.00164
SELL :
TARGET 1 : 0.00180
TARGET 2 : 0.00205
TARGET 3 : 0.00240
STOP LOS : 0.000120
2018-04-19 15:46:57 Free_Trade_Calls__AltSignals:TARGET
我有一些不完整的伪代码,但无论如何它主要是BS - 解析文本aynway的新手是
let now = new Date();
// var diff = (now.getTime() - date.getTime()) / 60000; // diff in min
const fs = require('fs'),
path = require('path'),
filePath = path.join(__dirname, 'chats.txt'),
// myString = "Free_Trade_Calls__AltSignals";
buy,
sell = [3],
sl;
let lines = [];
const buf = fs.readFileSync(filePath)
lines [] = buf.toString().split('\n'){
for (line < lines.length){
if (!err) {
if(line.indexOf("Trade_Calls__AltSignals: * / * (*)") > -1) {
currency = line.indexOf(2);
exchange = line.indexOf(4);
nextline();
while (line.indexOf($new.Date) < - 1){ // no containing Date
if (line.indexOf(buy) > -1 ){
line = buy
}
if (line.indexOf(buy) > -1 ){
}
}else{
nextline();
}
}
}
}
}