0.0.2
This commit is contained in:
parent
6b5ea57c89
commit
0503eb77bd
592
bot.js
592
bot.js
@ -1,21 +1,12 @@
|
|||||||
require('dotenv').config()
|
// Подключаем необходимые библиотеки
|
||||||
|
const { Telegraf, Scenes, session, Markup, Stage } = require('telegraf');
|
||||||
|
const { Op } = require('sequelize');
|
||||||
|
const sequelize = require('./db'); // Подключение базы данных
|
||||||
|
// Подключаем обработчики
|
||||||
|
const commands = require('./commands');
|
||||||
|
const utils = require('./utils');
|
||||||
|
const handlers = require('./handlers');
|
||||||
const {
|
const {
|
||||||
Telegraf,
|
|
||||||
Scenes,
|
|
||||||
session,
|
|
||||||
Stage,
|
|
||||||
Markup
|
|
||||||
} = require('telegraf')
|
|
||||||
const {
|
|
||||||
weaponshop,
|
|
||||||
slots,
|
|
||||||
rarecars,
|
|
||||||
simplecars,
|
|
||||||
houses,
|
|
||||||
cars,
|
|
||||||
phones,
|
|
||||||
weapons,
|
|
||||||
equipment,
|
|
||||||
UserModel,
|
UserModel,
|
||||||
WorldModel,
|
WorldModel,
|
||||||
JobModel,
|
JobModel,
|
||||||
@ -29,80 +20,7 @@ const {
|
|||||||
WarehouseModel,
|
WarehouseModel,
|
||||||
SaleModel,
|
SaleModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
mainChat,
|
} = global.config
|
||||||
adminList,
|
|
||||||
expToUp,
|
|
||||||
topSym
|
|
||||||
} = require('./config')
|
|
||||||
const {
|
|
||||||
profile,
|
|
||||||
bonus,
|
|
||||||
pay,
|
|
||||||
getprofile,
|
|
||||||
menu,
|
|
||||||
worldMenu,
|
|
||||||
referal,
|
|
||||||
jobs,
|
|
||||||
chooseJob,
|
|
||||||
casinoMenu,
|
|
||||||
work,
|
|
||||||
top,
|
|
||||||
propertyList,
|
|
||||||
propertyMenu,
|
|
||||||
propertyBuy,
|
|
||||||
propertySell,
|
|
||||||
hatkeisList,
|
|
||||||
organizationMenu,
|
|
||||||
workoff,
|
|
||||||
leaveOrg,
|
|
||||||
leaveOrgAccept,
|
|
||||||
payday,
|
|
||||||
orgMessage,
|
|
||||||
materialsBuy,
|
|
||||||
percentSet,
|
|
||||||
invite,
|
|
||||||
inviteAction,
|
|
||||||
report,
|
|
||||||
slotsMenu,
|
|
||||||
slotsRun,
|
|
||||||
promocodeActivate,
|
|
||||||
carContainers,
|
|
||||||
chooseContainer,
|
|
||||||
reportAnswer,
|
|
||||||
fastblock,
|
|
||||||
createPromo,
|
|
||||||
genPromo,
|
|
||||||
organizationCreate,
|
|
||||||
shot,
|
|
||||||
outmenu,
|
|
||||||
lobbyCreate,
|
|
||||||
lobbyMenu,
|
|
||||||
garage,
|
|
||||||
race
|
|
||||||
} = require('./commands')
|
|
||||||
const {
|
|
||||||
spaces,
|
|
||||||
spacesWithMarkdown,
|
|
||||||
escape,
|
|
||||||
generatePromo,
|
|
||||||
generateVoucher,
|
|
||||||
getCurrentTime,
|
|
||||||
getSlot,
|
|
||||||
giveExp,
|
|
||||||
matPriceUpdate,
|
|
||||||
rand,
|
|
||||||
random,
|
|
||||||
setCooldown,
|
|
||||||
weaponShopUpdate,
|
|
||||||
stats
|
|
||||||
} = require('./utils')
|
|
||||||
const {
|
|
||||||
handleError
|
|
||||||
} = require('./handlers')
|
|
||||||
const sequelize = require('./db');
|
|
||||||
const { Op } = require('sequelize');
|
|
||||||
const fs = require('fs');
|
|
||||||
const { createCanvas, loadImage } = require('canvas');
|
|
||||||
const bot = new Telegraf(process.env.BOT_TOKEN)
|
const bot = new Telegraf(process.env.BOT_TOKEN)
|
||||||
const crime = require('./scenes/crime')
|
const crime = require('./scenes/crime')
|
||||||
const pocketsteal = require('./scenes/pocketsteal')
|
const pocketsteal = require('./scenes/pocketsteal')
|
||||||
@ -113,26 +31,18 @@ const newpve = require('./scenes/newpve')
|
|||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
try {
|
try {
|
||||||
await sequelize.authenticate()
|
// Подключаемся к базе данных
|
||||||
await sequelize.sync()
|
await sequelize.authenticate();
|
||||||
|
console.log('Подключение к базе данных успешно!');
|
||||||
|
|
||||||
} catch (e) {
|
// Синхронизация моделей, если нужно
|
||||||
console.log('Подключение к бд сломалось', e)
|
await sequelize.sync({ alter: true });
|
||||||
}
|
console.log('Синхронизация моделей завершена.');
|
||||||
try {
|
|
||||||
await sequelize.authenticate()
|
// Запуск бота
|
||||||
await UserModel.sync({ alter: true })
|
console.log('Бот успешно запущен!');
|
||||||
await WorldModel.sync({ alter: true })
|
|
||||||
await JobModel.sync({ alter: true })
|
|
||||||
await PropertyModel.sync({ alter: true })
|
|
||||||
await BusinessModel.sync({ alter: true })
|
|
||||||
await ReportModel.sync({ alter: true })
|
|
||||||
await BlockModel.sync({ alter: true })
|
|
||||||
await PromocodeModel.sync()
|
|
||||||
await SkillsModel.sync({ alter: true })
|
|
||||||
console.log('Синхронизация завершена',)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Ошибка синхронизации', error)
|
console.error('Ошибка при запуске приложения:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +87,7 @@ bot.use(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
bot.use(stage)
|
bot.use(stage)
|
||||||
bot.use(stats)
|
bot.use(utils.stats)
|
||||||
|
|
||||||
bot.use(async (ctx, next) => {
|
bot.use(async (ctx, next) => {
|
||||||
bot.context.config = require('./ctxconfig.json')
|
bot.context.config = require('./ctxconfig.json')
|
||||||
@ -186,10 +96,10 @@ bot.use(async (ctx, next) => {
|
|||||||
if(username == null) username = ctx.from.id
|
if(username == null) username = ctx.from.id
|
||||||
switch(ctx.updateType){
|
switch(ctx.updateType){
|
||||||
case `message`:
|
case `message`:
|
||||||
console.log(getCurrentTime() + `: ` + username + `: ` + ctx.update.message.text)
|
console.log(utils.getCurrentTime() + `: ` + username + `: ` + ctx.update.message.text)
|
||||||
break;
|
break;
|
||||||
case `callback_query`:
|
case `callback_query`:
|
||||||
console.log(getCurrentTime() + `: ${username}: ${ctx.update.callback_query.data}`)
|
console.log(utils.getCurrentTime() + `: ${username}: ${ctx.update.callback_query.data}`)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(ctx)
|
console.log(ctx)
|
||||||
@ -297,15 +207,15 @@ bot.hears('промка', async(ctx) => {
|
|||||||
generatePromo()
|
generatePromo()
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.hears('▶️ Меню', menu);
|
bot.hears('▶️ Меню', commands.menu);
|
||||||
|
|
||||||
bot.hears('Чат', async (ctx) => {
|
bot.hears('Чат', async (ctx) => {
|
||||||
ctx.reply(`${ctx.message.chat.id}`)
|
ctx.reply(`${ctx.message.chat.id}`)
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.hears('😎 Профиль', profile);
|
bot.hears('😎 Профиль', commands.profile);
|
||||||
|
|
||||||
bot.command('getprofile', getprofile);
|
bot.command('getprofile', commands.getprofile);
|
||||||
|
|
||||||
bot.hears('Рандом', async (ctx) => {
|
bot.hears('Рандом', async (ctx) => {
|
||||||
let users = await UserModel.findAll();
|
let users = await UserModel.findAll();
|
||||||
@ -331,72 +241,72 @@ bot.hears('💳 Баланс', async (ctx) => {
|
|||||||
`);
|
`);
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.hears('🎁 Бонус', bonus)
|
bot.hears('🎁 Бонус', commands.bonus)
|
||||||
|
|
||||||
bot.hears('Гараж', garage)
|
bot.hears('Гараж', commands.garage)
|
||||||
|
|
||||||
bot.hears('Гонка', race)
|
bot.hears('Гонка', commands.race)
|
||||||
|
|
||||||
bot.command('pay', pay)
|
bot.command('pay', commands.pay)
|
||||||
|
|
||||||
bot.hears('Мир', worldMenu)
|
bot.hears('Мир', commands.worldMenu)
|
||||||
|
|
||||||
bot.hears('📞 Пригласить', referal)
|
bot.hears('📞 Пригласить', commands.referal)
|
||||||
|
|
||||||
bot.hears('📢 Вакансии', jobs)
|
bot.hears('📢 Вакансии', commands.jobs)
|
||||||
|
|
||||||
bot.action(/job_(1|2|3|4|5|6|7|leave)/, chooseJob)
|
bot.action(/job_(1|2|3|4|5|6|7|leave)/, commands.chooseJob)
|
||||||
|
|
||||||
bot.hears('🏯 Казино', casinoMenu)
|
bot.hears('🏯 Казино', commands.casinoMenu)
|
||||||
|
|
||||||
bot.hears('🗄️ Работать', work)
|
bot.hears('🗄️ Работать', commands.work)
|
||||||
|
|
||||||
bot.hears('Топ', top)
|
bot.hears('Топ', commands.top)
|
||||||
|
|
||||||
bot.hears('🔵 Имущество', propertyMenu)
|
bot.hears('🔵 Имущество', commands.propertyMenu)
|
||||||
|
|
||||||
bot.action('shopmenu', propertyMenu)
|
bot.action('shopmenu', commands.propertyMenu)
|
||||||
|
|
||||||
bot.action(/shop_(house|phone|car)/, propertyList)
|
bot.action(/shop_(house|phone|car)/, commands.propertyList)
|
||||||
|
|
||||||
bot.action(/{"action": "buy"*/, propertyBuy)
|
bot.action(/{"action": "buy"*/, commands.propertyBuy)
|
||||||
|
|
||||||
bot.hears('Поставщик', hatkeisList)
|
bot.hears('Поставщик', commands.hatkeisList)
|
||||||
|
|
||||||
bot.command('sell', propertySell)
|
bot.command('sell', commands.propertySell)
|
||||||
|
|
||||||
bot.hears('🌐 Организация', organizationMenu)
|
bot.hears('🌐 Организация', commands.organizationMenu)
|
||||||
|
|
||||||
bot.action('workoff', workoff)
|
bot.action('workoff', commands.workoff)
|
||||||
|
|
||||||
bot.action('покинуть', leaveOrg)
|
bot.action('покинуть', commands.leaveOrg)
|
||||||
|
|
||||||
bot.action('cancel', async (ctx) => {
|
bot.action('cancel', async (ctx) => {
|
||||||
await ctx.deleteMessage()
|
await ctx.deleteMessage()
|
||||||
await bot.telegram.answerCbQuery(ctx.callbackQuery.id, `Отмена.`)
|
await bot.telegram.answerCbQuery(ctx.callbackQuery.id, `Отмена.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.action('user_leave_business', leaveOrgAccept)
|
bot.action('user_leave_business', commands.leaveOrgAccept)
|
||||||
|
|
||||||
bot.action('payday', payday)
|
bot.action('payday', commands.payday)
|
||||||
|
|
||||||
bot.command('orgmessage', orgMessage)
|
bot.command('orgmessage', commands.orgMessage)
|
||||||
|
|
||||||
bot.command('materials', materialsBuy)
|
bot.command('materials', commands.materialsBuy)
|
||||||
|
|
||||||
bot.command('percent', percentSet)
|
bot.command('percent', commands.percentSet)
|
||||||
|
|
||||||
bot.command('business', organizationCreate)
|
bot.command('business', commands.organizationCreate)
|
||||||
|
|
||||||
bot.command('invite', invite)
|
bot.command('invite', commands.invite)
|
||||||
|
|
||||||
bot.action(/{"type": "business_invite_(accept|refuse)"*/, inviteAction)
|
bot.action(/{"type": "business_invite_(accept|refuse)"*/, commands.inviteAction)
|
||||||
|
|
||||||
bot.command('report', report)
|
bot.command('report', commands.report)
|
||||||
|
|
||||||
bot.hears('🎰 Слоты', slotsMenu)
|
bot.hears('🎰 Слоты', commands.slotsMenu)
|
||||||
|
|
||||||
bot.action(/slots(1000|5000|25000|50000|100000)/, slotsRun)
|
bot.action(/slots(1000|5000|25000|50000|100000)/, commands.slotsRun)
|
||||||
|
|
||||||
bot.hears('Помощь', async (ctx) => {
|
bot.hears('Помощь', async (ctx) => {
|
||||||
return await ctx.replyWithMarkdownV2(`• [Функционал](https://telegra.ph/CampFire-Bot-Info-09-25)\n• [Правила](https://telegra.ph/PRAVILA-BOTA-09-25)`, {
|
return await ctx.replyWithMarkdownV2(`• [Функционал](https://telegra.ph/CampFire-Bot-Info-09-25)\n• [Правила](https://telegra.ph/PRAVILA-BOTA-09-25)`, {
|
||||||
@ -404,11 +314,11 @@ bot.hears('Помощь', async (ctx) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.command('promocode', promocodeActivate)
|
bot.command('promocode', commands.promocodeActivate)
|
||||||
|
|
||||||
bot.hears('📦 Контейнеры', carContainers)
|
bot.hears('📦 Контейнеры', commands.carContainers)
|
||||||
|
|
||||||
bot.action(/container_(1|2|3|4|5|6|7|8|9|10)/, chooseContainer)
|
bot.action(/container_(1|2|3|4|5|6|7|8|9|10)/, commands.chooseContainer)
|
||||||
|
|
||||||
bot.action(/{"action": "sueta_*/, async (ctx) => {
|
bot.action(/{"action": "sueta_*/, async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
@ -436,86 +346,114 @@ bot.action(/{"action": "sueta_*/, async (ctx) => {
|
|||||||
|
|
||||||
/////////////////////////////////////Enterprise Update 20.12.2024//////////////////////////////////////////////////
|
/////////////////////////////////////Enterprise Update 20.12.2024//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Обновление меню "Предприятия"
|
||||||
bot.hears('🏗️ Предприятия', async (ctx) => {
|
bot.hears('🏗️ Предприятия', async (ctx) => {
|
||||||
return await ctx.reply(`
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
Меню предприятий
|
const warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } });
|
||||||
У вас: нет предприятий.
|
|
||||||
Цены:
|
|
||||||
|
|
||||||
`, Markup
|
const enterprises = await EnterpriseModel.findAll({
|
||||||
.inlineKeyboard([
|
where: { playerId: user.telegram_id }
|
||||||
[
|
});
|
||||||
{text: 'Мои предприятия', callback_data: `my_enterprises`},
|
|
||||||
{text: 'Построить', callback_data: `build_enterprise`},
|
|
||||||
{text: 'Склад', callback_data: `open_warehouse`},
|
|
||||||
]
|
|
||||||
])
|
|
||||||
.resize())
|
|
||||||
})
|
|
||||||
|
|
||||||
|
let message = `🏗️ Меню предприятий:\n`;
|
||||||
|
message += `У вас: ${enterprises.length} предприятий.\n`;
|
||||||
|
message += warehouse
|
||||||
|
? `🗄️ Единый склад: Доступен (Ёмкость: ${warehouse.capacity} ед.)\n`
|
||||||
|
: `🗄️ Единый склад: Не построен.\n`;
|
||||||
|
|
||||||
bot.action('my_enterprises', async (ctx) => {
|
const buttons = [];
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
|
||||||
let enterprises = await EnterpriseModel.findAll({
|
// Добавляем кнопки для предприятий
|
||||||
where: {
|
buttons.push([{ text: '🏭 Мои предприятия', callback_data: 'my_enterprises' }]);
|
||||||
playerId: user.telegram_id
|
buttons.push([{ text: '🛠️ Построить предприятие', callback_data: 'build_enterprise' }]);
|
||||||
}
|
|
||||||
})
|
// Кнопка для управления или постройки склада
|
||||||
let message = `Ваши предприятия:\n`
|
if (warehouse) {
|
||||||
enterprises.forEach(enterprise => {
|
buttons.push([{ text: '🚛 Управление складом', callback_data: 'manage_warehouse' }]);
|
||||||
message += `🏭 ${enterprise.name} (Тип: ${enterprise.resourceType}, Уровень: ${enterprise.level}, Производительность: ${enterprise.efficiency} ед/ч, Склад: ${enterprise.warehouseCapacity} ед.)\n`
|
} else {
|
||||||
})
|
buttons.push([{ text: '🗄️ Построить склад', callback_data: 'open_warehouse' }]);
|
||||||
if (enterprises.length === 0) {
|
|
||||||
message += 'У вас нет предприятий.\n'
|
|
||||||
}
|
}
|
||||||
return await ctx.reply(message)
|
|
||||||
})
|
|
||||||
|
|
||||||
bot.action('build_enterprise', async (ctx) => {
|
// Возвращаем меню с кнопками
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
return await ctx.reply(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
let enterprises = await EnterpriseModel.findAll({
|
});
|
||||||
where: {
|
|
||||||
playerId: user.telegram_id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (enterprises.length > 0) return await ctx.reply(`У вас уже есть предприятие.`)
|
|
||||||
|
|
||||||
let message = `Выберите тип предприятия (цена зависит от ресурса):`
|
|
||||||
let buttons = []
|
|
||||||
let types = ['wood', 'coal', 'oil', 'metall', 'gold', 'diamond']
|
|
||||||
types.forEach(type => {
|
|
||||||
let price = getResourcePrice(type) // Функция для получения стоимости
|
|
||||||
buttons.push({text: `${type} (Цена: ${price} монет)`, callback_data: `build_${type}`})
|
|
||||||
})
|
|
||||||
return await ctx.reply(message, Markup.inlineKeyboard(buttons).resize())
|
|
||||||
})
|
|
||||||
|
|
||||||
function getResourcePrice(resourceType) {
|
// Функция для преобразования типа ресурса в эмодзи
|
||||||
const prices = {
|
function getEnterpriseEmoji(resourceType) {
|
||||||
wood: 100,
|
const emojis = {
|
||||||
coal: 200,
|
wood: '🌳',
|
||||||
oil: 500,
|
coal: '⛏️',
|
||||||
metall: 1000,
|
oil: '🛢️',
|
||||||
gold: 3000,
|
metall: '⚒️',
|
||||||
diamond: 5000
|
gold: '💰',
|
||||||
|
diamond: '💎'
|
||||||
}
|
}
|
||||||
return prices[resourceType] || 0
|
return emojis[resourceType] || '🏭'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Построение предприятия
|
||||||
|
bot.action('build_enterprise', async (ctx) => {
|
||||||
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
const enterprises = await EnterpriseModel.findAll({
|
||||||
|
where: { playerId: user.telegram_id }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (enterprises.length >= 5) {
|
||||||
|
return await ctx.reply('Вы достигли максимального числа предприятий.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const resourcePrices = {
|
||||||
|
wood: 10000,
|
||||||
|
coal: 20000,
|
||||||
|
oil: 50000,
|
||||||
|
metall: 100000,
|
||||||
|
gold: 300000,
|
||||||
|
diamond: 500000
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = `🛠️ Постройка предприятия:\n`;
|
||||||
|
for (const [resource, price] of Object.entries(resourcePrices)) {
|
||||||
|
const resourceName = getResourceName(resource);
|
||||||
|
message += `${resourceName}: ${price} монет\n`;
|
||||||
|
}
|
||||||
|
message += '\nВыберите тип предприятия:';
|
||||||
|
|
||||||
|
const buttons = [
|
||||||
|
[
|
||||||
|
{ text: '🌲', callback_data: 'build_wood' },
|
||||||
|
{ text: '⛏️', callback_data: 'build_coal' }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ text: '🛢️', callback_data: 'build_oil' },
|
||||||
|
{ text: '⚙️', callback_data: 'build_metall' }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ text: '🥇', callback_data: 'build_gold' },
|
||||||
|
{ text: '💎', callback_data: 'build_diamond' }
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
return await ctx.reply(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Построение предприятия по выбранному типу
|
||||||
bot.action(/build_(wood|coal|oil|metall|gold|diamond)/, async (ctx) => {
|
bot.action(/build_(wood|coal|oil|metall|gold|diamond)/, async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
let data = ctx.update.callback_query.data
|
let data = ctx.update.callback_query.data
|
||||||
let type = data.split('_')[1]
|
let type = data.split('_')[1]
|
||||||
let price = getResourcePrice(type)
|
let price = getEnterprisePrice(type)
|
||||||
|
|
||||||
// Проверка, есть ли достаточно денег у пользователя
|
// Проверка, есть ли достаточно денег у пользователя
|
||||||
if (user.balance < price) {
|
if (user.balance < price) {
|
||||||
return await ctx.reply(`У вас недостаточно средств для постройки предприятия. Необходимо ${price} монет.`)
|
return await ctx.reply(`У вас недостаточно средств для постройки предприятия. Необходимо ${price} руб.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Строим предприятие
|
// Строим предприятие
|
||||||
|
let enterpriseName = `${user.username}'s ${getReadableType(type)}` // Название предприятия
|
||||||
let enterprise = await EnterpriseModel.create({
|
let enterprise = await EnterpriseModel.create({
|
||||||
name: `${type} mine`,
|
name: enterpriseName,
|
||||||
resourceType: type,
|
resourceType: type,
|
||||||
playerId: user.telegram_id,
|
playerId: user.telegram_id,
|
||||||
level: 1,
|
level: 1,
|
||||||
@ -524,9 +462,187 @@ bot.action(/build_(wood|coal|oil|metall|gold|diamond)/, async (ctx) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Снимаем деньги с баланса
|
// Снимаем деньги с баланса
|
||||||
await user.update({ balance: user.balance - price })
|
await user.update({ money: user.money - price })
|
||||||
|
|
||||||
return await ctx.reply(`Предприятие ${enterprise.name} построено!`)
|
return await ctx.reply(`Предприятие ${enterprise.name} (ID: ${enterprise.id}) построено!`)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Функция для расчета стоимости предприятия
|
||||||
|
function getEnterprisePrice(resourceType) {
|
||||||
|
const prices = {
|
||||||
|
wood: 5000,
|
||||||
|
coal: 10000,
|
||||||
|
oil: 20000,
|
||||||
|
metall: 50000,
|
||||||
|
gold: 150000,
|
||||||
|
diamond: 250000
|
||||||
|
}
|
||||||
|
return prices[resourceType] || 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Функция для преобразования типа ресурса в читаемое название
|
||||||
|
function getReadableType(type) {
|
||||||
|
const names = {
|
||||||
|
wood: 'Деревообрабатывающее предприятие',
|
||||||
|
coal: 'Угольное предприятие',
|
||||||
|
oil: 'Нефтяное предприятие',
|
||||||
|
metall: 'Металлургическое предприятие',
|
||||||
|
gold: 'Золотое предприятие',
|
||||||
|
diamond: 'Алмазное предприятие'
|
||||||
|
}
|
||||||
|
return names[type] || type
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.action('buy_warehouse', async (ctx) => {
|
||||||
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
if (user.money < 500000) {
|
||||||
|
return await ctx.reply(`У вас недостаточно средств для покупки склада.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
await WarehouseModel.create({
|
||||||
|
playerId: user.telegram_id,
|
||||||
|
capacity: 1000, // Начальная ёмкость
|
||||||
|
wood: 0,
|
||||||
|
coal: 0,
|
||||||
|
oil: 0,
|
||||||
|
metall: 0,
|
||||||
|
gold: 0,
|
||||||
|
diamond: 0
|
||||||
|
})
|
||||||
|
|
||||||
|
await user.update({ money: user.money - 500000 })
|
||||||
|
return await ctx.reply(`Вы успешно купили единый склад!`)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Управление складом
|
||||||
|
bot.action('manage_warehouse', async (ctx) => {
|
||||||
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
const warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } });
|
||||||
|
|
||||||
|
if (!warehouse) {
|
||||||
|
return await ctx.reply('У вас нет склада для управления.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = `🚛 Управление складом:\n`;
|
||||||
|
message += `Общая ёмкость: ${warehouse.capacity} ед.\n`;
|
||||||
|
message += `Хранимые ресурсы:\n`;
|
||||||
|
message += `🌲 Дерево: ${warehouse.wood || 0}\n`;
|
||||||
|
message += `⛏️ Уголь: ${warehouse.coal || 0}\n`;
|
||||||
|
message += `🛢️ Нефть: ${warehouse.oil || 0}\n`;
|
||||||
|
message += `⚙️ Металл: ${warehouse.metall || 0}\n`;
|
||||||
|
message += `🥇 Золото: ${warehouse.gold || 0}\n`;
|
||||||
|
message += `💎 Алмазы: ${warehouse.diamond || 0}\n`;
|
||||||
|
|
||||||
|
const buttons = [
|
||||||
|
[{ text: '➕ Перевести ресурсы', callback_data: 'transfer_resources' }],
|
||||||
|
[{ text: '📤 Продать со склада', callback_data: 'sell_from_warehouse' }],
|
||||||
|
[{ text: '🚚 Купить транспорт', callback_data: 'buy_truck' }]
|
||||||
|
];
|
||||||
|
|
||||||
|
return await ctx.reply(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
|
});
|
||||||
|
|
||||||
|
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.reply(message, Markup.inlineKeyboard([
|
||||||
|
[{ text: 'Управление транспортом', callback_data: 'manage_trucks' }],
|
||||||
|
[{ text: 'Продать ресурсы', callback_data: 'sell_from_warehouse' }]
|
||||||
|
]).resize())
|
||||||
|
})
|
||||||
|
|
||||||
|
// Управление предприятием
|
||||||
|
bot.action(/manage_(\d+)/, async (ctx) => {
|
||||||
|
let enterpriseId = ctx.match[1]
|
||||||
|
let enterprise = await EnterpriseModel.findByPk(enterpriseId)
|
||||||
|
|
||||||
|
if (!enterprise) return await ctx.reply(`Предприятие не найдено.`)
|
||||||
|
|
||||||
|
// Логика управления предприятием (например, прокачка или продажа ресурсов)
|
||||||
|
return await ctx.reply(`Вы управляете предприятием ${enterprise.name} (ID: ${enterprise.id}).`)
|
||||||
|
})
|
||||||
|
bot.action('transfer_resources', async (ctx) => {
|
||||||
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
const warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } });
|
||||||
|
|
||||||
|
if (!warehouse) {
|
||||||
|
return await ctx.reply('У вас нет единого склада.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const enterprises = await EnterpriseModel.findAll({
|
||||||
|
where: { playerId: user.telegram_id }
|
||||||
|
});
|
||||||
|
|
||||||
|
let message = `➕ Перевозка ресурсов:\n`;
|
||||||
|
message += `Общая ёмкость склада: ${warehouse.capacity} ед.\n`;
|
||||||
|
message += `Выберите предприятие для перевозки ресурсов:`;
|
||||||
|
|
||||||
|
const buttons = enterprises.map(ent => {
|
||||||
|
return [{ text: `🏭 ${ent.name}`, callback_data: `transfer_from_${ent.id}` }];
|
||||||
|
});
|
||||||
|
|
||||||
|
return await ctx.reply(message, Markup.inlineKeyboard(buttons).resize());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Перевозка с конкретного предприятия
|
||||||
|
bot.action(/transfer_from_(\d+)/, async (ctx) => {
|
||||||
|
const enterpriseId = ctx.match[1];
|
||||||
|
const user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
const warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } });
|
||||||
|
|
||||||
|
const enterprise = await EnterpriseModel.findByPk(enterpriseId);
|
||||||
|
if (!enterprise) {
|
||||||
|
return await ctx.reply('Предприятие не найдено.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = `🚛 Перевозка с предприятия ${enterprise.name}:\n`;
|
||||||
|
message += `🌲 Дерево: ${enterprise.wood || 0}\n`;
|
||||||
|
message += `⛏️ Уголь: ${enterprise.coal || 0}\n`;
|
||||||
|
message += `🛢️ Нефть: ${enterprise.oil || 0}\n`;
|
||||||
|
message += `⚙️ Металл: ${enterprise.metall || 0}\n`;
|
||||||
|
message += `🥇 Золото: ${enterprise.gold || 0}\n`;
|
||||||
|
message += `💎 Алмазы: ${enterprise.diamond || 0}\n`;
|
||||||
|
message += `\nВведите количество ресурса для перевозки.`;
|
||||||
|
|
||||||
|
return await ctx.reply(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.command('ent_rename', async (ctx) => {
|
||||||
|
let args = ctx.message.text.split(' ').slice(1)
|
||||||
|
if (args.length < 2) {
|
||||||
|
return await ctx.reply('Использование: /ent_rename <ID> <Новое название>')
|
||||||
|
}
|
||||||
|
|
||||||
|
let enterpriseId = parseInt(args[0])
|
||||||
|
let newName = args.slice(1).join(' ')
|
||||||
|
|
||||||
|
let enterprise = await EnterpriseModel.findByPk(enterpriseId)
|
||||||
|
if (!enterprise) {
|
||||||
|
return await ctx.reply(`Предприятие с ID ${enterpriseId} не найдено.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Переименовываем предприятие
|
||||||
|
await enterprise.update({ name: newName })
|
||||||
|
|
||||||
|
return await ctx.reply(`Предприятие (ID: ${enterprise.id}) переименовано в "${newName}".`)
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.action('upgrade_enterprise', async (ctx) => {
|
bot.action('upgrade_enterprise', async (ctx) => {
|
||||||
@ -620,20 +736,6 @@ bot.action(/sell_(\d+)/, async (ctx) => {
|
|||||||
return await ctx.reply(`Вы продали все ресурсы с ${enterprise.name} за ${totalSale} монет.`)
|
return await ctx.reply(`Вы продали все ресурсы с ${enterprise.name} за ${totalSale} монет.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.action('open_warehouse', 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(`У вас уже есть склад.`)
|
|
||||||
|
|
||||||
let newWarehouse = await WarehouseModel.create({
|
|
||||||
playerId: user.telegram_id,
|
|
||||||
capacity: 500 // Начальная ёмкость склада
|
|
||||||
})
|
|
||||||
|
|
||||||
return await ctx.reply(`Вы открыли новый склад!`)
|
|
||||||
})
|
|
||||||
|
|
||||||
bot.action('hire_truck', async (ctx) => {
|
bot.action('hire_truck', async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
let warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } })
|
let warehouse = await WarehouseModel.findOne({ where: { playerId: user.telegram_id } })
|
||||||
@ -650,18 +752,54 @@ bot.action('hire_truck', async (ctx) => {
|
|||||||
return await ctx.reply(`Вы наняли грузовик для транспортировки ресурсов!`)
|
return await ctx.reply(`Вы наняли грузовик для транспортировки ресурсов!`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function initializeResourcePrices() {
|
||||||
|
const resources = [
|
||||||
|
{ resourceType: 'wood', basePrice: 100, recoveryRate: 1 },
|
||||||
|
{ resourceType: 'coal', basePrice: 200, recoveryRate: 2 },
|
||||||
|
{ resourceType: 'oil', basePrice: 500, recoveryRate: 5 },
|
||||||
|
{ resourceType: 'metall', basePrice: 1000, recoveryRate: 10 },
|
||||||
|
{ resourceType: 'gold', basePrice: 3000, recoveryRate: 15 },
|
||||||
|
{ resourceType: 'diamond', basePrice: 5000, recoveryRate: 20 }
|
||||||
|
]
|
||||||
|
|
||||||
|
for (let resource of resources) {
|
||||||
|
await ResourcePriceModel.findOrCreate({
|
||||||
|
where: { resourceType: resource.resourceType },
|
||||||
|
defaults: {
|
||||||
|
currentPrice: resource.basePrice,
|
||||||
|
basePrice: resource.basePrice,
|
||||||
|
recoveryRate: resource.recoveryRate
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initializeResourcePrices()
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
const resources = await ResourcePriceModel.findAll()
|
||||||
|
for (let resource of resources) {
|
||||||
|
if (resource.currentPrice < resource.basePrice) {
|
||||||
|
resource.currentPrice += resource.recoveryRate
|
||||||
|
if (resource.currentPrice > resource.basePrice) {
|
||||||
|
resource.currentPrice = resource.basePrice
|
||||||
|
}
|
||||||
|
await resource.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 60000) // Обновляем цены каждые 60 секунд
|
||||||
|
|
||||||
/////////////////////////////////////Enterprise Update end//////////////////////////////////////////////////
|
/////////////////////////////////////Enterprise Update end//////////////////////////////////////////////////
|
||||||
|
|
||||||
/////////////////////////////////////Admin Commands//////////////////////////////////////////////////
|
/////////////////////////////////////Admin Commands//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
bot.command('answer', reportAnswer)
|
bot.command('answer', commands.reportAnswer)
|
||||||
|
|
||||||
bot.command('fastblock', fastblock)
|
bot.command('fastblock', commands.fastblock)
|
||||||
|
|
||||||
bot.command('createpromocode', createPromo)
|
bot.command('createpromocode', commands.createPromo)
|
||||||
|
|
||||||
bot.command('genpromo', genPromo)
|
bot.command('genpromo', commands.genPromo)
|
||||||
|
|
||||||
///////////////////////////////////////Functions//////////////////////////////////////////////////////
|
///////////////////////////////////////Functions//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
PromocodeModel
|
PromocodeModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
generateVoucher
|
generateVoucher
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BlockModel
|
BlockModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -2,10 +2,10 @@ const voucher_codes = require('voucher-code-generator');
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
PromocodeModel
|
PromocodeModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
generateVoucher
|
generateVoucher
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
ReportModel
|
ReportModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
WorldModel,
|
WorldModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
rand,
|
rand,
|
||||||
setCooldown
|
setCooldown
|
||||||
|
@ -3,10 +3,10 @@ const {
|
|||||||
simplecars,
|
simplecars,
|
||||||
UserModel,
|
UserModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces
|
spaces
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const {
|
const {
|
||||||
UserModel
|
UserModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -2,13 +2,13 @@ const {
|
|||||||
slots,
|
slots,
|
||||||
UserModel,
|
UserModel,
|
||||||
WorldModel
|
WorldModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
giveExp,
|
giveExp,
|
||||||
setCooldown
|
setCooldown
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -3,7 +3,7 @@ const {
|
|||||||
} = require('telegraf')
|
} = require('telegraf')
|
||||||
const {
|
const {
|
||||||
UserModel
|
UserModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -27,7 +27,7 @@ const {
|
|||||||
adminList,
|
adminList,
|
||||||
expToUp,
|
expToUp,
|
||||||
topSym
|
topSym
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
@ -43,7 +43,7 @@ const {
|
|||||||
setCooldown,
|
setCooldown,
|
||||||
weaponShopUpdate,
|
weaponShopUpdate,
|
||||||
stats
|
stats
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
// Получаем контекст canvas
|
// Получаем контекст canvas
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
PropertyModel,
|
PropertyModel,
|
||||||
expToUp
|
expToUp
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
escape
|
escape
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
PropertyModel,
|
PropertyModel,
|
||||||
expToUp
|
expToUp
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
escape
|
escape
|
||||||
|
@ -20,7 +20,7 @@ const {
|
|||||||
adminList,
|
adminList,
|
||||||
expToUp,
|
expToUp,
|
||||||
topSym
|
topSym
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
const {
|
|
||||||
UserModel,
|
|
||||||
JobModel
|
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
let user = await UserModel.findByPk(ctx.from.id);
|
let user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
@ -1,13 +1,3 @@
|
|||||||
const {
|
|
||||||
UserModel,
|
|
||||||
WorldModel,
|
|
||||||
JobModel
|
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
|
||||||
const {
|
|
||||||
giveExp,
|
|
||||||
setCooldown
|
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id);
|
let user = await UserModel.findByPk(ctx.from.id);
|
||||||
let job = await JobModel.findByPk(user.job);
|
let job = await JobModel.findByPk(user.job);
|
||||||
|
@ -5,10 +5,11 @@ const {
|
|||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
return await ctx.reply('Main Menu', Markup
|
return await ctx.reply('Main Menu', Markup
|
||||||
.keyboard([
|
.keyboard([
|
||||||
['😎 Профиль'],
|
['😎 Профиль'], // Row1 with 2 buttons
|
||||||
['🗄️ Работать', '🌐 Организация', '🎁 Бонус', '🏯 Казино'],
|
['🗄️ Работать', '🌐 Организация', '🎁 Бонус', '🏯 Казино'], // Row2 with 2 buttons
|
||||||
|
['🏗️ Предприятия'],
|
||||||
['📦 Контейнеры'],
|
['📦 Контейнеры'],
|
||||||
['📢 Вакансии', '🔵 Имущество', '📞 Пригласить']
|
['📢 Вакансии', '🔵 Имущество', '📞 Пригласить'] // Row3 with 3 buttons
|
||||||
])
|
])
|
||||||
.resize()
|
.resize()
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.args = ctx.update.message.text.split(' ')
|
ctx.args = ctx.update.message.text.split(' ')
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const sequelize = require('/workspace/degradin/Dev/Telegram/CampFire Play/db');
|
const sequelize = global.database
|
||||||
const { Op } = require('sequelize');
|
const { Op } = require('sequelize');
|
||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -6,7 +6,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
WorldModel,
|
WorldModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.args = ctx.update.message.text.split(' ')
|
ctx.args = ctx.update.message.text.split(' ')
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`)
|
if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`)
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
WorldModel,
|
WorldModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -4,11 +4,11 @@ const {
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
escape
|
escape
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -6,12 +6,12 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
WorldModel,
|
WorldModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
giveExp,
|
giveExp,
|
||||||
rand
|
rand
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = null
|
let user = null
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.args = ctx.update.message.text.split(' ')
|
ctx.args = ctx.update.message.text.split(' ')
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
BusinessModel
|
BusinessModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
escape,
|
escape,
|
||||||
setCooldown
|
setCooldown
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
WorldModel
|
WorldModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.args = ctx.update.message.text.split(' ')
|
ctx.args = ctx.update.message.text.split(' ')
|
||||||
|
@ -2,7 +2,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
PropertyModel,
|
PropertyModel,
|
||||||
expToUp
|
expToUp
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
escape
|
escape
|
||||||
|
@ -6,7 +6,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
PromocodeModel,
|
PromocodeModel,
|
||||||
adminList
|
adminList
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces
|
spaces
|
||||||
} = require('../utils')
|
} = require('../utils')
|
||||||
|
@ -3,12 +3,12 @@ const {
|
|||||||
} = require('telegraf')
|
} = require('telegraf')
|
||||||
const {
|
const {
|
||||||
weaponshop
|
weaponshop
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
escape,
|
escape,
|
||||||
weaponShopUpdate
|
weaponShopUpdate
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let text = `[Hatkeis Gunsmith](https://telegra.ph/Hatkeis-Gunsmith-09-27)\n`
|
let text = `[Hatkeis Gunsmith](https://telegra.ph/Hatkeis-Gunsmith-09-27)\n`
|
||||||
|
@ -20,7 +20,7 @@ const {
|
|||||||
adminList,
|
adminList,
|
||||||
expToUp,
|
expToUp,
|
||||||
topSym
|
topSym
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
@ -36,7 +36,7 @@ const {
|
|||||||
setCooldown,
|
setCooldown,
|
||||||
weaponShopUpdate,
|
weaponShopUpdate,
|
||||||
stats
|
stats
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -5,7 +5,7 @@ const {
|
|||||||
houses,
|
houses,
|
||||||
cars,
|
cars,
|
||||||
phones
|
phones
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let data = ctx.update.callback_query.data;
|
let data = ctx.update.callback_query.data;
|
||||||
|
@ -3,7 +3,7 @@ const {
|
|||||||
} = require('telegraf')
|
} = require('telegraf')
|
||||||
const {
|
const {
|
||||||
UserModel
|
UserModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id);
|
let user = await UserModel.findByPk(ctx.from.id);
|
||||||
|
@ -20,7 +20,7 @@ const {
|
|||||||
adminList,
|
adminList,
|
||||||
expToUp,
|
expToUp,
|
||||||
topSym
|
topSym
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
spacesWithMarkdown,
|
spacesWithMarkdown,
|
||||||
@ -36,7 +36,7 @@ const {
|
|||||||
setCooldown,
|
setCooldown,
|
||||||
weaponShopUpdate,
|
weaponShopUpdate,
|
||||||
stats
|
stats
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.args = ctx.update.message.text.split(' ')
|
ctx.args = ctx.update.message.text.split(' ')
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
const sequelize = require('/workspace/degradin/Dev/Telegram/CampFire Play/db');
|
const sequelize = global.database
|
||||||
const {
|
const {
|
||||||
rarecars,
|
rarecars,
|
||||||
simplecars,
|
simplecars,
|
||||||
UserModel,
|
UserModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
rand
|
rand
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let user = await UserModel.findByPk(ctx.from.id)
|
let user = await UserModel.findByPk(ctx.from.id)
|
||||||
|
@ -7,7 +7,7 @@ const {
|
|||||||
UserModel,
|
UserModel,
|
||||||
ReportModel,
|
ReportModel,
|
||||||
adminList
|
adminList
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const shortid = require('shortid');
|
const shortid = require('shortid');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const {
|
const {
|
||||||
UserModel,
|
UserModel,
|
||||||
topSym
|
topSym
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces
|
spaces
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils')
|
} = global.utils
|
||||||
const sequelize = require('../db');
|
const sequelize = global.database
|
||||||
const { Op } = require('sequelize');
|
const { Op } = require('sequelize');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const {
|
const {
|
||||||
WorldModel
|
WorldModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces
|
spaces
|
||||||
} = require('../utils')
|
} = require('../utils')
|
||||||
|
23
db.js
23
db.js
@ -1,13 +1,16 @@
|
|||||||
const {Sequelize} = require('sequelize');
|
const { Sequelize } = require('sequelize');
|
||||||
|
|
||||||
module.exports = new Sequelize(
|
// Использование переменных окружения для конфиденциальных данных
|
||||||
'campfire',
|
const sequelize = new Sequelize(
|
||||||
'bot',
|
process.env.DB_NAME, // Название базы данных
|
||||||
'Ka23ds05!',
|
process.env.DB_USER, // Пользователь
|
||||||
|
process.env.DB_PASSWORD, // Пароль
|
||||||
{
|
{
|
||||||
host: 'localhost',
|
host: process.env.DB_HOST, // Хост
|
||||||
port: '5432',
|
port: process.env.DB_PORT, // Порт
|
||||||
dialect: 'postgres',
|
dialect: 'postgres', // Диалект базы данных
|
||||||
logging: false
|
logging: false, // Отключение логирования запросов в консоль
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
|
module.exports = sequelize;
|
||||||
|
11
index.js
11
index.js
@ -1,2 +1,11 @@
|
|||||||
require('dotenv').config()
|
require('dotenv').config();
|
||||||
|
const sequelize = require('./db'); // Подключение базы данных
|
||||||
|
|
||||||
|
// Настраиваем глобальные переменные (опционально)
|
||||||
|
global.path = require('path');
|
||||||
|
global.config = require('./config'); // Конфигурация
|
||||||
|
global.database = sequelize; // База данных
|
||||||
|
global.utils = require('./utils');
|
||||||
|
|
||||||
|
// Инициализация бота
|
||||||
require('./bot')
|
require('./bot')
|
@ -25,7 +25,7 @@ const Enterprise = sequelize.define('enterprise', {
|
|||||||
playerId: {
|
playerId: {
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER,
|
||||||
references: {
|
references: {
|
||||||
model: 'Users',
|
model: 'users',
|
||||||
key: 'telegram_id'
|
key: 'telegram_id'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
models/resourceprice.model.js
Normal file
32
models/resourceprice.model.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
const sequelize = require('../db');
|
||||||
|
const {DataTypes} = require('sequelize');
|
||||||
|
|
||||||
|
const ResourcePriceModel = sequelize.define('resource_price', {
|
||||||
|
resource: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
unique: true, // Уникальное значение для каждого ресурса
|
||||||
|
},
|
||||||
|
price: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 0, // Базовая цена
|
||||||
|
},
|
||||||
|
basePrice: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 0, // Цена, к которой возвращается при восстановлении
|
||||||
|
},
|
||||||
|
fluctuationRate: {
|
||||||
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 0.1, // Коэффициент изменения цены при продаже
|
||||||
|
},
|
||||||
|
recoveryRate: {
|
||||||
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 0.01, // Коэффициент восстановления цены
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = ResourcePriceModel;
|
@ -1,31 +1,12 @@
|
|||||||
const sequelize = require('../db');
|
const sequelize = require('../db');
|
||||||
const {Sequelize} = require('sequelize');
|
const {DataTypes} = require('sequelize');
|
||||||
|
|
||||||
const Sale = sequelize.define('sale', {
|
const Sale = sequelize.define('sale', {
|
||||||
enterpriseId: {
|
resourceType: DataTypes.STRING,
|
||||||
type: Sequelize.INTEGER,
|
currentPrice: DataTypes.FLOAT,
|
||||||
references: {
|
basePrice: DataTypes.FLOAT,
|
||||||
model: 'Enterprises',
|
recoveryRate: DataTypes.FLOAT // Скорость восстановления цены к базовой
|
||||||
key: 'id'
|
})
|
||||||
}
|
|
||||||
},
|
|
||||||
resourceType: {
|
|
||||||
type: Sequelize.STRING, // тип ресурса
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
quantity: {
|
|
||||||
type: Sequelize.INTEGER, // количество продаваемого ресурса
|
|
||||||
defaultValue: 0
|
|
||||||
},
|
|
||||||
salePrice: {
|
|
||||||
type: Sequelize.FLOAT, // цена за единицу ресурса
|
|
||||||
defaultValue: 100
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
type: Sequelize.DATE, // время продажи
|
|
||||||
defaultValue: Sequelize.NOW
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = Sale;
|
module.exports = Sale;
|
||||||
|
@ -1,40 +1,21 @@
|
|||||||
const sequelize = require('../db');
|
const sequelize = require('../db');
|
||||||
const {Sequelize} = require('sequelize');
|
const {DataTypes} = require('sequelize');
|
||||||
|
|
||||||
const Warehouse = sequelize.define('warehouse', {
|
const Warehouse = sequelize.define('warehouse', {
|
||||||
playerId: {
|
playerId: DataTypes.INTEGER,
|
||||||
type: Sequelize.INTEGER,
|
capacity: DataTypes.INTEGER, // Общая ёмкость склада
|
||||||
references: {
|
wood: DataTypes.INTEGER,
|
||||||
model: 'Users',
|
coal: DataTypes.INTEGER,
|
||||||
key: 'id'
|
oil: DataTypes.INTEGER,
|
||||||
}
|
metall: DataTypes.INTEGER,
|
||||||
},
|
gold: DataTypes.INTEGER,
|
||||||
capacity: {
|
diamond: DataTypes.INTEGER,
|
||||||
type: Sequelize.INTEGER, // ёмкость общего склада
|
})
|
||||||
defaultValue: 500
|
|
||||||
},
|
|
||||||
logisticsLevel: {
|
|
||||||
type: Sequelize.INTEGER, // уровень логистики
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const Truck = sequelize.define('truck', {
|
const Truck = sequelize.define('truck', {
|
||||||
warehouseId: {
|
warehouseId: DataTypes.INTEGER,
|
||||||
type: Sequelize.INTEGER,
|
capacity: DataTypes.INTEGER, // Сколько может перевезти за час
|
||||||
references: {
|
efficiency: DataTypes.INTEGER // Частота транспортировки (количество операций в час)
|
||||||
model: 'Warehouses',
|
})
|
||||||
key: 'id'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
capacity: {
|
|
||||||
type: Sequelize.INTEGER, // сколько ресурсов грузовик может вывозить в час
|
|
||||||
defaultValue: 10
|
|
||||||
},
|
|
||||||
efficiency: {
|
|
||||||
type: Sequelize.INTEGER, // эффективность грузовика (на сколько быстрее он может работать)
|
|
||||||
defaultValue: 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Warehouse, Truck;
|
module.exports = Warehouse, Truck;
|
||||||
|
25
package-lock.json
generated
25
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "telegram-bot-course",
|
"name": "campfiregamebot",
|
||||||
"version": "1.0.0",
|
"version": "0.0.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "telegram-bot-course",
|
"name": "campfiregamebot",
|
||||||
"version": "1.0.0",
|
"version": "0.0.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
@ -17,6 +17,7 @@
|
|||||||
"pg-hstore": "^2.3.3",
|
"pg-hstore": "^2.3.3",
|
||||||
"pm2": "^5.3.0",
|
"pm2": "^5.3.0",
|
||||||
"sequelize": "^6.6.2",
|
"sequelize": "^6.6.2",
|
||||||
|
"shortid": "^2.2.16",
|
||||||
"telegraf": "^4.13.1",
|
"telegraf": "^4.13.1",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"voucher-code-generator": "^1.3.0"
|
"voucher-code-generator": "^1.3.0"
|
||||||
@ -1158,6 +1159,12 @@
|
|||||||
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
|
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/nanoid": {
|
||||||
|
"version": "2.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
|
||||||
|
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/needle": {
|
"node_modules/needle": {
|
||||||
"version": "2.4.0",
|
"version": "2.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz",
|
||||||
@ -1883,6 +1890,16 @@
|
|||||||
"integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==",
|
"integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==",
|
||||||
"license": "BSD-2-Clause"
|
"license": "BSD-2-Clause"
|
||||||
},
|
},
|
||||||
|
"node_modules/shortid": {
|
||||||
|
"version": "2.2.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.16.tgz",
|
||||||
|
"integrity": "sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==",
|
||||||
|
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"nanoid": "^2.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/signal-exit": {
|
"node_modules/signal-exit": {
|
||||||
"version": "3.0.7",
|
"version": "3.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
||||||
|
13
package.json
13
package.json
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "telegram-bot-course",
|
"name": "campfiregamebot",
|
||||||
"version": "1.0.0",
|
"version": "0.0.2",
|
||||||
"description": "",
|
"description": "CampFire Game Telegram Bot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nodemon index.js",
|
"dev": "nodemon index.js",
|
||||||
"start": "node index.js"
|
"start": "node index.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "Degradin",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
@ -19,8 +19,13 @@
|
|||||||
"pg-hstore": "^2.3.3",
|
"pg-hstore": "^2.3.3",
|
||||||
"pm2": "^5.3.0",
|
"pm2": "^5.3.0",
|
||||||
"sequelize": "^6.6.2",
|
"sequelize": "^6.6.2",
|
||||||
|
"shortid": "^2.2.16",
|
||||||
"telegraf": "^4.13.1",
|
"telegraf": "^4.13.1",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"voucher-code-generator": "^1.3.0"
|
"voucher-code-generator": "^1.3.0"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.campfiregg.ru/degradin/CampFirePlay"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
WorldModel,
|
WorldModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
@ -19,7 +19,7 @@ const {
|
|||||||
rand,
|
rand,
|
||||||
random,
|
random,
|
||||||
setCooldown
|
setCooldown
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils');
|
} = global.utils;
|
||||||
const crime = new Scenes.BaseScene('Crime');
|
const crime = new Scenes.BaseScene('Crime');
|
||||||
|
|
||||||
crime.enter( async (ctx) => {
|
crime.enter( async (ctx) => {
|
||||||
|
@ -11,7 +11,7 @@ UserModel,
|
|||||||
WorldModel,
|
WorldModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
@ -20,7 +20,7 @@ rand,
|
|||||||
random,
|
random,
|
||||||
setCooldown,
|
setCooldown,
|
||||||
drop
|
drop
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils');
|
} = global.utils;
|
||||||
const newpve = new Scenes.BaseScene('NEWPVE');
|
const newpve = new Scenes.BaseScene('NEWPVE');
|
||||||
const resultTier = [
|
const resultTier = [
|
||||||
{hit: 'Head', droprate: 10},
|
{hit: 'Head', droprate: 10},
|
||||||
|
@ -11,7 +11,7 @@ UserModel,
|
|||||||
WorldModel,
|
WorldModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
@ -19,7 +19,7 @@ giveExp,
|
|||||||
rand,
|
rand,
|
||||||
random,
|
random,
|
||||||
setCooldown
|
setCooldown
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils');
|
} = global.utils;
|
||||||
const steal = new Scenes.BaseScene('POCKET_STEAL');
|
const steal = new Scenes.BaseScene('POCKET_STEAL');
|
||||||
|
|
||||||
steal.enter(async (ctx) => {
|
steal.enter(async (ctx) => {
|
||||||
|
@ -11,7 +11,7 @@ UserModel,
|
|||||||
WorldModel,
|
WorldModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
@ -20,7 +20,7 @@ rand,
|
|||||||
random,
|
random,
|
||||||
setCooldown,
|
setCooldown,
|
||||||
drop
|
drop
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils');
|
} = global.utils;
|
||||||
const pve = new Scenes.BaseScene('PVE');
|
const pve = new Scenes.BaseScene('PVE');
|
||||||
|
|
||||||
pve.enter(async (ctx) => {
|
pve.enter(async (ctx) => {
|
||||||
|
@ -11,7 +11,7 @@ UserModel,
|
|||||||
WorldModel,
|
WorldModel,
|
||||||
SkillsModel,
|
SkillsModel,
|
||||||
PropertyModel
|
PropertyModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const {
|
const {
|
||||||
spaces,
|
spaces,
|
||||||
getSlot,
|
getSlot,
|
||||||
@ -19,7 +19,7 @@ giveExp,
|
|||||||
rand,
|
rand,
|
||||||
random,
|
random,
|
||||||
setCooldown
|
setCooldown
|
||||||
} = require('/dev/Telegram/CampFireGameBot/utils');
|
} = global.utils;
|
||||||
const shop = new Scenes.BaseScene('SHOP_ROBBERY');
|
const shop = new Scenes.BaseScene('SHOP_ROBBERY');
|
||||||
|
|
||||||
bot.on('callback_query', (ctx) => {
|
bot.on('callback_query', (ctx) => {
|
||||||
|
@ -5,7 +5,7 @@ const bot = new Telegraf(process.env.BOT_TOKEN)
|
|||||||
const {
|
const {
|
||||||
PromocodeModel,
|
PromocodeModel,
|
||||||
mainChat
|
mainChat
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const voucher_codes = require('voucher-code-generator');
|
const voucher_codes = require('voucher-code-generator');
|
||||||
const rand = require('./rand')
|
const rand = require('./rand')
|
||||||
const generateVoucher = require('./generateVoucher');
|
const generateVoucher = require('./generateVoucher');
|
||||||
|
@ -4,7 +4,7 @@ const {
|
|||||||
const bot = new Telegraf(process.env.BOT_TOKEN)
|
const bot = new Telegraf(process.env.BOT_TOKEN)
|
||||||
const {
|
const {
|
||||||
expToUp
|
expToUp
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
|
|
||||||
module.exports = async (user, experience) => {
|
module.exports = async (user, experience) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const rand = require('./rand')
|
const rand = require('./rand')
|
||||||
const {
|
const {
|
||||||
WorldModel
|
WorldModel
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
let world = await WorldModel.findByPk(1)
|
let world = await WorldModel.findByPk(1)
|
||||||
|
@ -12,7 +12,7 @@ const rtOP = io.metric({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// const usersCountIO = io.metric({
|
// const usersCountIO = io.metric({
|
||||||
// name: 'Users count',
|
// name: 'global.User count',
|
||||||
// unit: 'user'
|
// unit: 'user'
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const {
|
|||||||
weaponshop,
|
weaponshop,
|
||||||
weapons,
|
weapons,
|
||||||
equipment,
|
equipment,
|
||||||
} = require('/dev/Telegram/CampFireGameBot/config')
|
} = global.config
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user