This commit is contained in:
Degradin 2025-01-16 10:30:22 +03:00
parent fea61dc362
commit 8f6089b68b
7 changed files with 1003 additions and 11 deletions

18
bot.js
View File

@ -241,9 +241,21 @@ bot.hears('🛡️ Test', async (ctx) => {
ctx.reply(`🚨 Добро пожаловать в тестовый режим 🚨\nВесь функционал в этом режиме еще не сбалансирован\n`, Markup.inlineKeyboard(buttons)); ctx.reply(`🚨 Добро пожаловать в тестовый режим 🚨\nВесь функционал в этом режиме еще не сбалансирован\n`, Markup.inlineKeyboard(buttons));
}) })
bot.hears('Криминал', async (ctx) => { bot.command('profile', (ctx) => {
await ctx.scene.enter('Crime') return ctx.reply('👤 Ваш профиль:', {
}) reply_markup: {
inline_keyboard: [
[
{
text: "Открыть профиль",
web_app: { url: "https://cmpfire.ru:3000/profile" }, // Замените на ваш URL
},
],
],
},
});
});
bot.hears('промка', async (ctx) => { bot.hears('промка', async (ctx) => {

View File

@ -1,4 +1,5 @@
require('dotenv').config(); require('dotenv').config();
const sequelize = require('./db'); // Подключение базы данных const sequelize = require('./db'); // Подключение базы данных
// Настраиваем глобальные переменные (опционально) // Настраиваем глобальные переменные (опционально)
@ -9,3 +10,4 @@ global.utils = require('./utils');
// Инициализация бота // Инициализация бота
require('./bot') require('./bot')
require('./server'); // Подключение модуля API

887
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,15 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@faker-js/faker": "^9.3.0", "@faker-js/faker": "^9.3.0",
"body": "^5.1.0",
"body-parser": "^1.20.3",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"error-stack-parser": "^2.1.4", "error-stack-parser": "^2.1.4",
"express": "^4.21.2",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"node-schedule": "^2.1.1", "node-schedule": "^2.1.1",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
"parser": "^0.1.4",
"pg": "^8.6.0", "pg": "^8.6.0",
"pg-hstore": "^2.3.3", "pg-hstore": "^2.3.3",
"pm2": "^5.3.0", "pm2": "^5.3.0",

65
public/index.html Normal file
View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Профиль</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.profile {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.profile h1 {
margin: 0 0 10px;
}
.profile p {
margin: 5px 0;
}
</style>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<div class="profile">
<h1 id="username">Загрузка...</h1>
<p>Уровень: <span id="level"></span></p>
<p>Опыт: <span id="exp"></span> / <span id="expToNextLevel"></span></p>
<p>Баланс: <span id="money"></span></p>
<p>Дом: <span id="house"></span></p>
<p>Машина: <span id="car"></span></p>
<p>Телефон: <span id="mobile"></span></p>
</div>
<script>
// Telegram WebApp API
const tg = window.Telegram.WebApp;
// Получаем ID пользователя
const userId = tg.initDataUnsafe.user.id;
// Загружаем данные профиля
fetch(`/profile/${userId}`)
.then((response) => response.json())
.then((data) => {
document.getElementById('username').textContent = data.username;
document.getElementById('level').textContent = data.level;
document.getElementById('exp').textContent = data.exp;
document.getElementById('expToNextLevel').textContent = data.expToNextLevel;
document.getElementById('money').textContent = data.money;
document.getElementById('house').textContent = data.house;
document.getElementById('car').textContent = data.car;
document.getElementById('mobile').textContent = data.mobile;
})
.catch((err) => {
console.error('Ошибка загрузки профиля:', err);
});
</script>
</body>
</html>

8
rpg.js
View File

@ -21,14 +21,6 @@ const {
StolenCardsModel, StolenCardsModel,
WorldModel, WorldModel,
PropertyModel, PropertyModel,
AFKPropertyModel,
BusinessModel,
BlockModel,
EnterpriseModel,
WarehouseModel,
TruckModel,
ResourcePriceModel,
SkillsModel,
DailyModel, DailyModel,
logs logs
} = global.config } = global.config

30
server.js Normal file
View File

@ -0,0 +1,30 @@
const express = require('express');
const app = express();
const { UserModel, PropertyModel, expToUp } = global.config;
// Настраиваем сервер для выдачи статических файлов
app.use(express.static('public'));
// Эндпоинт для получения данных профиля
app.get('/profile/:id', async (req, res) => {
const id = req.params.id;
const user = await UserModel.findByPk(id);
const property = await PropertyModel.findByPk(id);
if (!user) return res.status(404).send({ error: 'Пользователь не найден' });
res.send({
username: user.username,
level: user.level,
exp: user.exp,
expToNextLevel: expToUp[user.level],
money: user.money,
house: property.house ? property.house.name : "Бездомный",
car: property.car1 ? property.car1.name : "Пешком",
mobile: property.mobile ? property.mobile.name : "Нет",
});
});
// Запуск сервера
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Сервер запущен на порту ${PORT}`));