Update bot.js
This commit is contained in:
parent
404298f48d
commit
c7a5bdea26
65
bot.js
65
bot.js
@ -439,7 +439,6 @@ bot.action('my_enterprises', async (ctx) => {
|
|||||||
for (const enterprise of enterprises) {
|
for (const enterprise of enterprises) {
|
||||||
const { id, name, level, efficiency, currentResources, resourceType, warehouseCapacity } = enterprise;
|
const { id, name, level, efficiency, currentResources, resourceType, warehouseCapacity } = enterprise;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
message += `🔹 [ID: ${id}] ${getEnterpriseEmoji(resourceType)} ${name} st. ${level}\n └── ${currentResources}/${warehouseCapacity} [${efficiency} ед/ч]\n\n`;
|
message += `🔹 [ID: ${id}] ${getEnterpriseEmoji(resourceType)} ${name} st. ${level}\n └── ${currentResources}/${warehouseCapacity} [${efficiency} ед/ч]\n\n`;
|
||||||
|
|
||||||
const truck = await TruckModel.findOne({ where: { enterpriseId: id } });
|
const truck = await TruckModel.findOne({ where: { enterpriseId: id } });
|
||||||
@ -465,9 +464,6 @@ bot.action('my_enterprises', async (ctx) => {
|
|||||||
}
|
}
|
||||||
message += '\n\n[📈 - Улучшить]\n[🛻 - Нанять грузовик]\n 🚛 - Улучшить грузовик\n[💰 - Продать ресурсы с предприятия]\n[🔄 - Перевезти все на склад]'
|
message += '\n\n[📈 - Улучшить]\n[🛻 - Нанять грузовик]\n 🚛 - Улучшить грузовик\n[💰 - Продать ресурсы с предприятия]\n[🔄 - Перевезти все на склад]'
|
||||||
buttons.push([{ text: '⬅️ Назад', callback_data: 'back_to_menu' }]);
|
buttons.push([{ text: '⬅️ Назад', callback_data: 'back_to_menu' }]);
|
||||||
=======
|
|
||||||
buttons.push([{ text: '⬅️ Назад', callback_data: 'enterprise_menu' }]);
|
|
||||||
>>>>>>> 4d02f482ae2574632f331fc7af4fe4c1a6842a9d
|
|
||||||
|
|
||||||
return await ctx.editMessageText(message, Markup.inlineKeyboard(buttons).resize());
|
return await ctx.editMessageText(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
});
|
});
|
||||||
@ -619,36 +615,6 @@ bot.action('manage_warehouse', async (ctx) => {
|
|||||||
return await ctx.editMessageText(message, Markup.inlineKeyboard(buttons).resize());
|
return await ctx.editMessageText(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
});
|
});
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
bot.action('warehouse_management', async (ctx) => {
|
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
|
||||||
let warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } })
|
|
||||||
|
|
||||||
if (!warehouse) {
|
|
||||||
return await ctx.reply(`У вас нет склада. Вы можете купить его за 500,000 руб.`, Markup.inlineKeyboard([
|
|
||||||
[{ text: 'Купить склад', callback_data: 'buy_warehouse' }]
|
|
||||||
]).resize())
|
|
||||||
}
|
|
||||||
|
|
||||||
let message = `
|
|
||||||
🏗️ Единый склад
|
|
||||||
Емкость: ${warehouse.capacity} ед.
|
|
||||||
Ресурсы:
|
|
||||||
🌲 Дерево: ${warehouse.wood || 0}
|
|
||||||
⛏️ Уголь: ${warehouse.coal || 0}
|
|
||||||
🛢️ Нефть: ${warehouse.oil || 0}
|
|
||||||
🛠️ Металл: ${warehouse.metall || 0}
|
|
||||||
💰 Золото: ${warehouse.gold || 0}
|
|
||||||
💎 Алмазы: ${warehouse.diamond || 0}
|
|
||||||
`
|
|
||||||
return await ctx.editMessageText(message, Markup.inlineKeyboard([
|
|
||||||
[{ text: 'Управление транспортом', callback_data: 'manage_trucks' }],
|
|
||||||
[{ text: 'Продать ресурсы', callback_data: 'sell_from_warehouse' }]
|
|
||||||
]).resize())
|
|
||||||
})
|
|
||||||
|
|
||||||
>>>>>>> 4d02f482ae2574632f331fc7af4fe4c1a6842a9d
|
|
||||||
// Управление предприятием
|
// Управление предприятием
|
||||||
bot.action(/manage_(\d+)/, async (ctx) => {
|
bot.action(/manage_(\d+)/, async (ctx) => {
|
||||||
let enterpriseId = ctx.match[1]
|
let enterpriseId = ctx.match[1]
|
||||||
@ -660,11 +626,7 @@ bot.action(/manage_(\d+)/, async (ctx) => {
|
|||||||
[{ text: 'Нанять грузовик', callback_data: 'hire_truck' }]
|
[{ text: 'Нанять грузовик', callback_data: 'hire_truck' }]
|
||||||
];
|
];
|
||||||
// Логика управления предприятием (например, прокачка или продажа ресурсов)
|
// Логика управления предприятием (например, прокачка или продажа ресурсов)
|
||||||
<<<<<<< HEAD
|
|
||||||
return await ctx.reply(`Вы управляете предприятием ${enterprise.name} (ID: ${enterprise.id}).`, Markup.inlineKeyboard(buttons).resize())
|
return await ctx.reply(`Вы управляете предприятием ${enterprise.name} (ID: ${enterprise.id}).`, Markup.inlineKeyboard(buttons).resize())
|
||||||
=======
|
|
||||||
return await ctx.editMessageText(`Вы управляете предприятием ${enterprise.name} (ID: ${enterprise.id}).`)
|
|
||||||
>>>>>>> 4d02f482ae2574632f331fc7af4fe4c1a6842a9d
|
|
||||||
})
|
})
|
||||||
bot.action('transfer_resources', async (ctx) => {
|
bot.action('transfer_resources', async (ctx) => {
|
||||||
const user = await UserModel.findByPk(ctx.from.id);
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
@ -798,35 +760,8 @@ bot.action('sell_resources', async (ctx) => {
|
|||||||
where: { playerId: user.telegram_id }
|
where: { playerId: user.telegram_id }
|
||||||
});
|
});
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (enterprises.length === 0) {
|
if (enterprises.length === 0) {
|
||||||
return await ctx.reply('У вас нет предприятий для продажи ресурсов.');
|
return await ctx.reply('У вас нет предприятий для продажи ресурсов.');
|
||||||
=======
|
|
||||||
if (enterprises.length === 0) return await ctx.reply(`У вас нет предприятий для продажи ресурсов.`)
|
|
||||||
|
|
||||||
let buttons = []
|
|
||||||
enterprises.forEach(enterprise => {
|
|
||||||
buttons.push({ text: `Продать ресурсы с ${enterprise.name}`, callback_data: `sell_${enterprise.id}` })
|
|
||||||
})
|
|
||||||
|
|
||||||
return await ctx.editMessageText(`Выберите предприятие для продажи ресурсов:`, Markup.inlineKeyboard(buttons).resize())
|
|
||||||
})
|
|
||||||
|
|
||||||
bot.action(/sell_(\d+)/, async (ctx) => {
|
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
|
||||||
let enterpriseId = ctx.match[1]
|
|
||||||
let enterprise = await EnterpriseModel.findByPk(enterpriseId)
|
|
||||||
|
|
||||||
if (!enterprise) return await ctx.reply(`Предприятие не найдено.`)
|
|
||||||
|
|
||||||
// Логика продажи ресурсов с предприятия
|
|
||||||
const resourceQuantity = await ResourceModel.findOne({
|
|
||||||
where: { playerId: user.telegram_id, type: enterprise.resourceType }
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!resourceQuantity || resourceQuantity.quantity <= 0) {
|
|
||||||
return await ctx.reply(`У вас нет ресурсов для продажи на предприятии ${enterprise.name}.`)
|
|
||||||
>>>>>>> 4d02f482ae2574632f331fc7af4fe4c1a6842a9d
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = 'Список ваших предприятий и их ресурсы:\n\n';
|
let message = 'Список ваших предприятий и их ресурсы:\n\n';
|
||||||
|
Loading…
Reference in New Issue
Block a user