const TelegramBot = require('node-telegram-bot-api');

const token = process.env.BOTTOKEN;

const bot = new TelegramBot(token, { polling: true });

bot.on('message', (msg) => {

    var hi = "hi";
    if (msg.text.toString().toLowerCase().indexOf(hi) === 0) {
        bot.sendMessage(msg.chat.id, "Hello " + msg.from.first_name + " Please type /start");
    }

    var bye = "bye";
    if (msg.text.toString().toLowerCase().includes(bye)) {
        bot.sendMessage(msg.chat.id, "Hope to see you around again , Bye");
    }

    // const faq = "faq";
    // if (msg.text.toString().toLocaleLowerCase().includes(faq)) {
    //     // bot.sendMessage(msg.chat.id, "Here are Frequently Asked Questions");
    //     // bot.sendMessage(msg.chat.id, "Please only ask an Admin, if you can't find the answer here..");
    // }


}),
    bot.onText(/^(\/start|Home)$/, (msg) => {

        bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", {
            "reply_markup": {
                "keyboard": [["FAQ", "Applications"]]
            }
        })

    })


bot.onText(/FAQ/, (msg) => {
    bot.sendMessage(msg.chat.id, "Frequently Asked Questions")
        .then(() => {
            return bot.sendMessage(msg.chat.id, "Please only ask an Admin, if you can't find the answer here..", {
                "reply_markup": {
                    "keyboard": [["Subscriptions", "IPTV"], ["Home"]]
                }
            })
        })
})


bot.onText(/Subscriptions/, (msg) => {
    bot.sendMessage(msg.chat.id, "Please only ask an Admin, if you can't find the answer here..", {
        "reply_markup": {
            "keyboard": [["Subscription Prices"],
            ["How to get a subscription?"],
            ["Subscriptions URLs", "Can I stream on multiple devices?"],
            ["Updates Group"],
            ["Install FileLinked on FireStick", "Install FileLinked on Android"],
            ["Home"]]
        }
    })
})