0 votes
in Programming by (580 points)

I'm a beginner with JS and wrote this little program where at a certain point, I should pass this "rsi" inside my other function (where in bold) but I can't get it right. (this program generates an error)

I read about middleware and "state" command, but I still cannot apply it. Do I also need to pass "next" inside the rsi = async () as parameter?

const Telegram = require('telegraf/telegram');
var cryptoSMA = require('crypto-sma');
const ichimokuCloud = require('trading-indicator').ichimokuCloud

alerts = require('trading-indicator').alerts

const bot = new Telegraf('18a9o9Y');
const regex = /#\w+\//g;

const helpMessage = `
Say something to me
/start - start the bot
/help - command reference
`;

bot.start((ctx) => {
    ctx.reply("Hi I am echoo bot");
    ctx.reply(helpMessage);
})

// Usage:
rsi = async () => {
    let rsi = (await alerts.rsiCheck(14, 75, 25, 'binance', 'BTC/USDT', '15m', false));
    console.log(rsi);
};
 
rsi();

 
cross();
 

bot.on("text", (ctx) => {
    let input = ctx.message.text;
    
    let inputArray = input.split("#");
    
    console.log(inputArray);
    

    let message = "";

   
    inputArray.shift();  
    message = inputArray.join(" ");
        
    let messageArray =  message.split("/");
    console.log(messageArray);


    ctx.reply("/p " + messageArray[0]);
    
    **ctx.reply(rsi);**

    
  })


bot.launch()

Please log in or register to answer this question.

...