const {
    Markup
} = require('telegraf')
const {
    weaponshop
} = global.config
const {
    spaces,
    escape,
    weaponShopUpdate
} = global.utils

module.exports = async (ctx) => {
    let text = `[Hatkeis Gunsmith](https://telegra.ph/Hatkeis-Gunsmith-09-27)\n`
    let shop = `\n  Вы подходите к зданию с вывеской "Ништяки Хаткейса".\n      Вот ассортимент на сегодня\n`
    let prodArray = []
    for (i in weaponshop) {
        prodArray.push({text: i, callback_data: `{"action": "buy", "type": "equipment", "value": "${i}"}`})
        shop += `${i}. ${weaponshop[i].name} (¤${spaces(weaponshop[i].price)})\n`
    }
    prodArray.push({text: `Назад`, callback_data: `shopmenu`})
    let rows = []
    while (prodArray.length > 0) {
        rows.push(prodArray.splice(0, 5)) // разбиваем на подмассивы по 5 кнопок
    }
    return await ctx.replyWithMarkdownV2(text + escape(shop),
    {
    reply_markup: {
        inline_keyboard: rows
    },
    disable_web_page_preview: true})
}