diff --git a/bot.js b/bot.js index 9adeb1f..0039962 100644 --- a/bot.js +++ b/bot.js @@ -23,7 +23,8 @@ const { SaleModel, ResourcePriceModel, SkillsModel, - DailyModel + DailyModel, + logMiddleware } = global.config const bot = new Telegraf(process.env.BOT_TOKEN) const rpg = require('./rpg'); // Подключение RPG-механик @@ -76,7 +77,6 @@ bot.telegram.setMyCommands([{ description: "Создать жалобу/обращение/идею." } ]) - bot.use(stage.middleware()) bot.use(rpg) @@ -211,11 +211,19 @@ bot.command('start', async (ctx) => { ['🎁 Бонус'], ['📦 Контейнеры'], ['📢 Вакансии', '🔵 Имущество', '📞 Пригласить'], + ['🛡️ Test'], ]) .resize() ) }) +bot.hears('🛡️ Test', async (ctx) => { + const buttons = [ + [Markup.button.callback('PVE', 'locations')], + ]; + ctx.reply(`🚨 Добро пожаловать в тестовый режим 🚨\nВесь функционал в этом режиме еще не сбалансирован\n`, Markup.inlineKeyboard(buttons)); +}) + bot.hears('Криминал', async (ctx) => { await ctx.scene.enter('Crime') }) diff --git a/config/index.js b/config/index.js index cea7dbe..34a807e 100644 --- a/config/index.js +++ b/config/index.js @@ -57,4 +57,6 @@ module.exports = { 343500, 349550, 355650, 361800, 368000 ], topSym : ['🥇', '🥈', '🥉', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟', '🌫️', '🌫️', '🌫️', '🌫️', '🌫️'], + logs: require('../utils/logs'), + logMiddleware: require('../utils/logMiddleware'), } \ No newline at end of file diff --git a/json/logs.json b/json/logs.json new file mode 100644 index 0000000..d5dded7 --- /dev/null +++ b/json/logs.json @@ -0,0 +1,1122 @@ +{ + "timestamp": "2025-01-14T15:59:07.614Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Охота", + "extraData": { + "location": { + "id": 1, + "name": "Заброшенный склад", + "description": "Темный склад с кучей мусора.", + "enemies": [ + 1, + 2, + 3 + ], + "level": 1, + "loot": [ + 6, + 7 + ], + "rarity": 1, + "createdAt": "2025-01-11T19:47:41.517Z", + "updatedAt": "2025-01-11T19:47:41.517Z" + } + } +} +{ + "timestamp": "2025-01-14T15:59:20.753Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Охота", + "extraData": { + "location": { + "id": 2, + "name": "Лесопосадка", + "description": "Густой лес с опасными тропами.", + "enemies": [ + 2, + 3, + 4 + ], + "level": 2, + "loot": [ + 8, + 9 + ], + "rarity": 2, + "createdAt": "2025-01-11T19:47:42.625Z", + "updatedAt": "2025-01-11T19:47:42.625Z" + } + } +} +{ + "timestamp": "2025-01-14T16:07:50.367Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:07:52.208Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:07:53.630Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:07:59.011Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:07:59.376Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:08:00.612Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:08:03.430Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:08:17.939Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "action": "Основа", + "extraData": {} +} +{ + "timestamp": "2025-01-14T16:18:50.803Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "message", + "data": { + "text": "😎 Профиль", + "message_id": 108293 + } +} +{ + "timestamp": "2025-01-14T16:19:04.153Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "message", + "data": { + "text": "🏗️ Предприятия", + "message_id": 108295 + } +} +{ + "timestamp": "2025-01-14T16:19:10.423Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "my_enterprises", + "id": "1182903943914863731" + } +} +{ + "timestamp": "2025-01-14T16:19:27.053Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "message", + "data": { + "text": "CampFireGG.Crime", + "message_id": 108297 + } +} +{ + "timestamp": "2025-01-14T16:19:30.489Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "rpg_profile", + "id": "1182903942829303866" + } +} +{ + "timestamp": "2025-01-14T16:20:35.618Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "view_cards", + "id": "1182903943337991293" + } +} +{ + "timestamp": "2025-01-14T16:20:47.416Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "message", + "data": { + "text": "/steal_card", + "message_id": 108300 + } +} +{ + "timestamp": "2025-01-14T16:20:56.617Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "view_cards", + "id": "1182903941727041086" + } +} +{ + "timestamp": "2025-01-14T16:20:59.615Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "brutecard_48", + "id": "1182903944517397335" + } +} +{ + "timestamp": "2025-01-14T16:20:59.651Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Брутфорс карты", + "extraData": { + "card": { + "id": 48, + "userId": "275416286", + "balance": 14400, + "cardNumber": "6533-6250-5574-4159-4351", + "pin": "0874", + "cvv": "182", + "holderName": "Della Goyette", + "bankName": "Kunze, McKenzie and Medhurst", + "expiresDate": "6/2026", + "createdAt": "2025-01-14T16:20:47.421Z", + "updatedAt": "2025-01-14T16:20:47.421Z" + }, + "inventory": [ + { + "id": 20, + "telegram_id": "275416286", + "name": "Пистолет Админа", + "text_id": "2dc0d68d-2ab4-4d00-926b-608c86c1110d", + "description": "Ганчик", + "effectData": [ + { + "type": "damage_boost", + "amount": 50 + } + ], + "price": 55000, + "rarity": 1, + "type": "weapon", + "duration": null, + "canBeEquipped": true, + "equipped": true, + "createdAt": "2025-01-10T07:42:04.085Z", + "updatedAt": "2025-01-12T22:04:10.287Z" + }, + { + "id": 72, + "telegram_id": "275416286", + "name": "Легкая Аптечка", + "text_id": "small_aid_kit", + "description": "Минимальный набор первой помощи. Восстанавливает 10 HP. Подходит для небольших травм.", + "effectData": [ + { + "type": "heal", + "amount": 10 + } + ], + "price": 1000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": true, + "equipped": false, + "createdAt": "2025-01-12T22:05:17.012Z", + "updatedAt": "2025-01-12T22:05:17.012Z" + }, + { + "id": 74, + "telegram_id": "275416286", + "name": "Легкая Аптечка", + "text_id": "small_aid_kit", + "description": "Минимальный набор первой помощи. Восстанавливает 10 HP. Подходит для небольших травм.", + "effectData": [ + { + "type": "heal", + "amount": 10 + } + ], + "price": 1000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": true, + "equipped": false, + "createdAt": "2025-01-12T22:05:19.907Z", + "updatedAt": "2025-01-12T22:05:19.907Z" + }, + { + "id": 75, + "telegram_id": "275416286", + "name": "Легкая Аптечка", + "text_id": "small_aid_kit", + "description": "Минимальный набор первой помощи. Восстанавливает 10 HP. Подходит для небольших травм.", + "effectData": [ + { + "type": "heal", + "amount": 10 + } + ], + "price": 1000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": true, + "equipped": false, + "createdAt": "2025-01-12T22:05:21.598Z", + "updatedAt": "2025-01-12T22:05:21.598Z" + }, + { + "id": 22, + "telegram_id": "275416286", + "name": "Очки Ботаника", + "text_id": "glasses_botanic", + "description": "Толстые очки с массивной оправой. Придаёт вашему персонажу умный вид. Увеличивает интеллект на 1.", + "effectData": [ + { + "type": "intelligence_boost", + "amount": 25 + } + ], + "price": 25000, + "rarity": 1, + "type": "accessory", + "duration": null, + "canBeEquipped": true, + "equipped": true, + "createdAt": "2025-01-10T09:18:04.111Z", + "updatedAt": "2025-01-12T22:06:23.806Z" + }, + { + "id": 25, + "telegram_id": "275416286", + "name": "Сим-карта", + "text_id": "simcard", + "description": "Обычная SIM-карта для доступа к мобильной сети.", + "effectData": null, + "price": 10000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": false, + "equipped": false, + "createdAt": "2025-01-10T09:20:21.170Z", + "updatedAt": "2025-01-10T09:20:21.170Z" + }, + { + "id": 43, + "telegram_id": "275416286", + "name": "Эмулятор картридера", + "text_id": "cardreader_emulator", + "description": "Устройство для эмуляции работы картридеров, незаменимое для тех, кто занимается брутфорсом банковских карт. Одноразовое использование.", + "effectData": null, + "price": 5000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": false, + "equipped": false, + "createdAt": "2025-01-10T09:57:28.642Z", + "updatedAt": "2025-01-10T09:57:28.642Z" + }, + { + "id": 44, + "telegram_id": "275416286", + "name": "Эмулятор картридера", + "text_id": "cardreader_emulator", + "description": "Устройство для эмуляции работы картридеров, незаменимое для тех, кто занимается брутфорсом банковских карт. Одноразовое использование.", + "effectData": null, + "price": 5000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": false, + "equipped": false, + "createdAt": "2025-01-10T09:57:30.047Z", + "updatedAt": "2025-01-10T09:57:30.047Z" + }, + { + "id": 45, + "telegram_id": "275416286", + "name": "Эмулятор картридера", + "text_id": "cardreader_emulator", + "description": "Устройство для эмуляции работы картридеров, незаменимое для тех, кто занимается брутфорсом банковских карт. Одноразовое использование.", + "effectData": null, + "price": 5000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": false, + "equipped": false, + "createdAt": "2025-01-10T09:57:32.172Z", + "updatedAt": "2025-01-10T09:57:32.172Z" + }, + { + "id": 57, + "telegram_id": "275416286", + "name": "Стимулятор", + "text_id": "stimulator_25", + "description": "Восстанавливает 25 стамины.", + "effectData": [ + { + "type": "stamina_recover", + "amount": 25 + } + ], + "price": 5000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": true, + "equipped": false, + "createdAt": "2025-01-11T15:26:53.936Z", + "updatedAt": "2025-01-11T15:26:53.936Z" + } + ], + "emulator": { + "id": 43, + "telegram_id": "275416286", + "name": "Эмулятор картридера", + "text_id": "cardreader_emulator", + "description": "Устройство для эмуляции работы картридеров, незаменимое для тех, кто занимается брутфорсом банковских карт. Одноразовое использование.", + "effectData": null, + "price": 5000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": false, + "equipped": false, + "createdAt": "2025-01-10T09:57:28.642Z", + "updatedAt": "2025-01-10T09:57:28.642Z" + } + } +} +{ + "timestamp": "2025-01-14T16:24:33.548Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "brute_fail_48_2", + "id": "1182903941240577988" + } +} +{ + "timestamp": "2025-01-14T16:26:53.400Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "type": "message", + "data": { + "text": "😎 Профиль", + "message_id": 108304 + } +} +{ + "timestamp": "2025-01-14T16:26:57.927Z", + "user": { + "id": 536939960, + "username": "vladislav_korn", + "first_name": "Vladyslav", + "last_name": "Korn" + }, + "chat": { + "id": -1001895132127, + "type": "supergroup" + }, + "type": "message", + "data": { + "text": "шо русачки как терпится", + "message_id": 11272 + } +} +{ + "timestamp": "2025-01-14T16:27:07.183Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "type": "message", + "data": { + "text": "🎁 Бонус", + "message_id": 108306 + } +} +{ + "timestamp": "2025-01-14T16:27:09.104Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "type": "message", + "data": { + "text": "🏗️ Предприятия", + "message_id": 108308 + } +} +{ + "timestamp": "2025-01-14T16:27:09.432Z", + "user": { + "id": 536939960, + "username": "vladislav_korn", + "first_name": "Vladyslav", + "last_name": "Korn" + }, + "chat": { + "id": -1001895132127, + "type": "supergroup" + }, + "type": "message", + "data": { + "text": "нет текста", + "message_id": 11273 + } +} +{ + "timestamp": "2025-01-14T16:27:10.504Z", + "user": { + "id": 5128359608, + "username": "she1lby", + "first_name": "Дима", + "last_name": "" + }, + "chat": { + "id": 5128359608, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "my_enterprises", + "id": "3579392725151399894" + } +} +{ + "timestamp": "2025-01-14T16:35:32.844Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "enterprise_menu", + "id": "1182903943854890414" + } +} +{ + "timestamp": "2025-01-14T16:35:37.889Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "message", + "data": { + "text": "CampFireGG.Crime", + "message_id": 108310 + } +} +{ + "timestamp": "2025-01-14T16:35:38.947Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "rpg_profile", + "id": "1182903944584471530" + } +} +{ + "timestamp": "2025-01-14T16:35:40.136Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "inventory", + "id": "1182903941612657061" + } +} +{ + "timestamp": "2025-01-14T16:35:44.381Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "type": "callback_query", + "data": { + "data": "view_item_72", + "id": "1182903943470673262" + } +} +{ + "timestamp": "2025-01-14T16:35:44.418Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Просмотр предмета", + "extraData": { + "item": { + "id": 72, + "telegram_id": "275416286", + "name": "Легкая Аптечка", + "text_id": "small_aid_kit", + "description": "Минимальный набор первой помощи. Восстанавливает 10 HP. Подходит для небольших травм.", + "effectData": [ + { + "type": "heal", + "amount": 10 + } + ], + "price": 1000, + "rarity": 1, + "type": "consumable", + "duration": null, + "canBeEquipped": true, + "equipped": false, + "createdAt": "2025-01-12T22:05:17.012Z", + "updatedAt": "2025-01-12T22:05:17.012Z" + } + } +} +{ + "timestamp": "2025-01-14T16:37:02.633Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697623253, + "stamina": 90 + } +} +{ + "timestamp": "2025-01-14T17:00:10.743Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Охота", + "extraData": { + "location": { + "id": 7, + "name": "Центр кибернетики", + "description": "Лаборатория передовых технологий, захваченная преступниками.", + "enemies": [ + 12, + 13 + ], + "level": 6, + "loot": [], + "rarity": 3, + "createdAt": "2025-01-14T16:57:49.586Z", + "updatedAt": "2025-01-14T16:57:49.586Z" + } + } +} +{ + "timestamp": "2025-01-14T17:03:52.174Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 90 + } +} +{ + "timestamp": "2025-01-14T17:03:55.591Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 80 + } +} +{ + "timestamp": "2025-01-14T17:04:02.074Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 70 + } +} +{ + "timestamp": "2025-01-14T17:04:06.309Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 60 + } +} +{ + "timestamp": "2025-01-14T17:04:13.698Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 50 + } +} +{ + "timestamp": "2025-01-14T17:04:17.587Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 40 + } +} +{ + "timestamp": "2025-01-14T17:04:21.164Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 30 + } +} +{ + "timestamp": "2025-01-14T17:04:26.342Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 20 + } +} +{ + "timestamp": "2025-01-14T17:04:29.924Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 10 + } +} +{ + "timestamp": "2025-01-14T17:04:30.552Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Сумка)", + "extraData": { + "baseChance": 20, + "chance": 36, + "randomRoll": 14, + "moneyIn": 27577 + } +} +{ + "timestamp": "2025-01-14T17:04:33.542Z", + "user": { + "id": 805814188, + "username": "Mana_Terroristo", + "first_name": "Егор", + "last_name": "" + }, + "chat": { + "id": 805814188, + "type": "private" + }, + "action": "Карманная кража (Start)", + "extraData": { + "cdBefore": 1697887440, + "stamina": 0 + } +} +{ + "timestamp": "2025-01-14T17:08:46.120Z", + "user": { + "id": 275416286, + "username": "Degradin", + "first_name": "eval(rm -rf /*)", + "last_name": "" + }, + "chat": { + "id": 275416286, + "type": "private" + }, + "action": "Охота", + "extraData": { + "location": { + "id": 1, + "name": "Заброшенный склад", + "description": "Темный склад с кучей мусора.", + "enemies": [ + 1, + 2, + 3 + ], + "level": 1, + "loot": [ + 6, + 7 + ], + "rarity": 1, + "createdAt": "2025-01-11T19:47:41.517Z", + "updatedAt": "2025-01-11T19:47:41.517Z" + } + } +} diff --git a/rpg.js b/rpg.js index 060c380..549c874 100644 --- a/rpg.js +++ b/rpg.js @@ -28,7 +28,8 @@ const { TruckModel, ResourcePriceModel, SkillsModel, - DailyModel + DailyModel, + logs } = global.config const rpg = new Composer(); @@ -37,7 +38,6 @@ rpg.use(async (ctx, next) => { let id = ctx.from.id let username = ctx.from.username; if (username == null) username = ctx.from.id; - const currentTime = utils.getCurrentTime(); switch (ctx.updateType) { @@ -482,7 +482,6 @@ rpg.action(/brutecard_/, async (ctx) => { if (!emulator) { return ctx.reply('Для запуска брутфорса вам нужен "Эмулятор картридера".'); } - // Удаляем "Эмулятор картридера" из инвентаря await InventoryModel.destroy({ where: { id: emulator.id } }); @@ -519,7 +518,7 @@ rpg.action(/brutecard_/, async (ctx) => { const keyboard = Markup.inlineKeyboard( rows.sort(() => Math.random() - 0.5).map((row) => row) // Сортируем строки кнопок случайным образом ); - + logs(ctx, "Брутфорс карты", {card: card, keyboard: keyboard, emulator: emulator}); // Отправляем сообщение с клавиатурой await ctx.reply( `💳 Брутфорс карты\n @@ -587,6 +586,7 @@ rpg.action(/brute_fail_/, async (ctx) => { const keyboard = Markup.inlineKeyboard( rows.sort(() => Math.random() - 0.5).map((row) => row) ); + logs(ctx, "Брутфорс карты (Fail)", {card: card, keyboard: keyboard}); // Обновляем сообщение с клавиатурой await ctx.editMessageText( @@ -616,7 +616,7 @@ rpg.action(/brute_success_/, async (ctx) => { delete attempts[ctx.from.id]; const amount = card.balance; // Сумма денег за карточку const character = await CharacterModel.findByPk(ctx.from.id); - + logs(ctx, "Брутфорс карты (Success)", {card: card, amount: amount}); // Увеличиваем грязные деньги пользователя character.dirtymoney += amount; await character.save(); @@ -670,6 +670,7 @@ rpg.action(`POCKET_ACTION`, async (ctx) => { if (character.pocketstealcd > cooldown.currentTime) return ctx.editMessageText(`📛 Данное действие будет доступно через ${cooldown.timeLeftInMinutes} мин.`); character.pocketstealcd = cooldown.endTime character.stamina -= 10 + logs(ctx, "Карманная кража (Start)", { cdBefore: pocketsteal, cdAfter: character.pocketstealcd, stamina: character.stamina }); character.save() ctx.editMessageText('Выберите объект', Markup.inlineKeyboard([ [ @@ -710,6 +711,7 @@ rpg.action(`MONEY_IN_POCKET`, async (ctx) => { let moneyIn = utils.rand(5, 1000); Exp(ctx, character, character.intelligence + 3) character.dirtymoney += moneyIn; + logs(ctx, "Карманная кража (Кошелек)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, moneyIn: moneyIn}); await character.save(); return ctx.editMessageText(`Вы успешно украли Ð${utils.spaces(moneyIn)} из кармана.`); }); @@ -735,6 +737,7 @@ rpg.action(`PHONE`, async (ctx) => { return await ctx.reply(`Вы сбыли украденный ${phones[randPhone].name} за Ð${utils.spaces(dirtyMoney)}`) } property.mobile = phones[randPhone] + logs(ctx, "Карманная кража (Телефон)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, phone: phones[randPhone]}); await character.save() await property.save() return ctx.editMessageText(`Вы успешно украли ${phones[randPhone].name} из кармана.`) @@ -763,6 +766,7 @@ rpg.action(`MONEY_IN_WALLET`, async (ctx) => { let moneyIn = utils.rand(1000, 10000) Exp(ctx, character, character.intelligence + 5) character.dirtymoney += moneyIn + logs(ctx, "Карманная кража (Бумажник)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, moneyIn: moneyIn}); character.save() return ctx.editMessageText(`Вы успешно украли Ð${utils.spaces(moneyIn)} из бумажника.`) }); @@ -778,7 +782,8 @@ rpg.action(`CARD_IN_WALLET`, async (ctx) => { return ctx.editMessageText('Вы были замечены во время кражи.') } Exp(ctx, character, character.intelligence + 7) - generateCard(ctx.from.id) + let newCard = generateCard(ctx.from.id) + logs(ctx, "Карманная кража (Карта)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, card: newCard}); character.save() return ctx.editMessageText(`Вы успешно украли 💳 из бумажника.`) }); @@ -820,6 +825,7 @@ rpg.action(`POCKET_BAG`, async (ctx) => { } Exp(ctx, character, character.intelligence + times) character.dirtymoney += moneyIn + logs(ctx, "Карманная кража (Сумка)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, moneyIn: moneyIn}); character.save() return ctx.editMessageText(`Вы успешно украли сумку и сбыли все ценности из нее:\n${text}\nОбщий куш: Ð${utils.spaces(moneyIn)}`) }); @@ -848,6 +854,7 @@ rpg.action('SHOP_ACTION', async (ctx) => { if (character.shoprobcd > cooldown.currentTime) return ctx.editMessageText(`📛 Данное действие будет доступно через ${cooldown.timeLeftInMinutes} мин.`); character.shoprobcd = cooldown.endTime character.stamina -= 25 + logs(ctx, "Ограбление магазина (Start)", {cdBefore: shoprobcd, cdAfter: character.shoprobcd, stamina: character.stamina}); character.save() return ctx.editMessageText('Стадии:', Markup.inlineKeyboard([ [{ text: 'Взлом кассы', callback_data: `SHOP_CASH_BREAK` }], @@ -865,6 +872,7 @@ rpg.action(`SHOP_CASH_BREAK`, async (ctx) => { if (chance < randomRoll) { const keyboard = generateKeyboard(); ctx.deleteMessage() + logs(ctx, "Ограбление магазина (Взлом кассы ручной)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, keyboard: keyboard, cashIn: cashIn}); return ctx.reply('Касса закрыта, вы начали взлом замка:', keyboard); //ctx.editMessageText('Вы начали взлом кассы.'); //return ctx.scene.enter('LOCKPICK') @@ -884,6 +892,7 @@ rpg.action(`SHOP_CASH_BREAK`, async (ctx) => { [{ text: 'Завершить ограбление', callback_data: `SHOP_END` }] ])) }, timer + 300) + logs(ctx, "Ограбление магазина (Взлом кассы быстро)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, cashIn: cashIn}); }); rpg.action(`SHOP_CASH_SMASH`, async (ctx) => { @@ -913,6 +922,7 @@ rpg.action(`SHOP_CASH_SMASH`, async (ctx) => { [{ text: 'Завершить ограбление', callback_data: `SHOP_END` }] ])) }, timer + 300) + logs(ctx, "Ограбление магазина (Разбитие кассы)", {baseChance: baseChance, chance: chance, randomRoll: randomRoll, cashIn: cashIn}); }); rpg.action(`SHOP_CASH_BREAK_SUCCESS`, async (ctx) => { @@ -936,6 +946,7 @@ rpg.action(`SHOP_CASH_BREAK_SUCCESS`, async (ctx) => { [{ text: 'Завершить ограбление', callback_data: `SHOP_END` }] ])) }, timer + 300) + logs(ctx, "Ограбление магазина (Взлом кассы)", {cashIn: cashIn}); }); rpg.action(`SHOP_END`, async (ctx) => { @@ -959,9 +970,10 @@ rpg.action(/lock_*/, async (ctx) => { // Проверяем, не исчерпаны ли попытки if (attempts[userId] >= 5) { delete attempts[userId]; // Сбрасываем попытки после провала + logs(ctx, "Взлом замка (Full Fail)", {attempts: attempts[userId]}); return ctx.editMessageText('Взлом провалился. Замок остается нетронутым.'); } - + logs(ctx, "Взлом замка (Fail)", {attempts: attempts[userId]}); // Ответ на нажатие кнопки ctx.answerCbQuery(`Штифт не сдвинулся. Попыток осталось: ${5 - attempts[userId]}`); removeButton(ctx, buttonId); @@ -1014,7 +1026,6 @@ rpg.action('inventory', async (ctx) => { ), ]; buttons.push(Markup.button.callback('🔙 В меню', 'crime_menu')); - await ctx.editMessageText(message, Markup.inlineKeyboard(buttons, { columns: 2 })); } catch (error) { console.error('Ошибка при выводе инвентаря:', error); @@ -1048,8 +1059,8 @@ rpg.action(/view_item_(\d+)/, async (ctx) => { if (item.equipped && item.canBeEquipped) { buttons.push([Markup.button.callback(`🚫 Снять ${item.name}`, `unequip_item_${item.id}`)]); } - - await ctx.replyWithMarkdown(message, Markup.inlineKeyboard(buttons, { columns: 2 })); + logs(ctx, "Просмотр предмета", {item: item}); + await ctx.reply(message, Markup.inlineKeyboard(buttons, { columns: 2 })); }); rpg.action(/use_item_(\d+)/, async (ctx) => { @@ -1521,32 +1532,6 @@ const fillEnemies = async () => { console.log("Enemies filled."); }; -const fillLocations = async () => { - const locations = [ - { - name: "Заброшенный склад", - description: "Темный склад с кучей мусора.", - enemies: [1, 2, 3], - level: 1, - loot: [6, 7], - rarity: 1 - }, - { - name: "Лесопосадка", - description: "Густой лес с опасными тропами.", - enemies: [2, 3, 4], - level: 2, - loot: [8, 9], - rarity: 2 - }, - ]; - - for (const location of locations) { - await Location.create(location); - } - console.log("Locations filled."); -}; - const generateBattles = async () => { const locations = await Location.findAll(); @@ -1592,14 +1577,17 @@ const generateBattles = async () => { generateBattles() schedule.scheduleJob('0 * * * *', generateBattles); // Каждый час в начале часа -rpg.command("locations", async (ctx) => { + + + +rpg.action("locations", async (ctx) => { const locations = await Location.findAll(); if (!locations.length) { return ctx.reply("Нет доступных локаций для исследования."); } const locationButtons = locations.map((location) => ({ - text: location.name, + text: location.name + ` (${location.level} lvl.)`, callback_data: `viewlocation_${location.id}`, })); @@ -1628,7 +1616,7 @@ rpg.action(/viewlocation_\d+/, async (ctx) => { [{ text: "Охота", callback_data: `hunt_location_${location.id}` }], ]); - await ctx.reply(description, keyboard); + await ctx.editMessageText(description, keyboard); }); rpg.action(/hunt_location_\d+/, async (ctx) => { @@ -1643,7 +1631,7 @@ rpg.action(/hunt_location_\d+/, async (ctx) => { if (!character) { return ctx.reply("Ваш персонаж не найден."); } - + logs(ctx, "Охота", {location: location}); const inventory = await InventoryModel.findAll({ where: { telegram_id: ctx.from.id } }); const hasGrenadeLow = inventory.some((item) => item.text_id === "grenade_low"); const hasGrenadeMedium = inventory.some((item) => item.text_id === "grenade_medium"); @@ -1651,7 +1639,7 @@ rpg.action(/hunt_location_\d+/, async (ctx) => { const enemyIds = location.enemies || []; if (enemyIds.length === 0) { - return ctx.reply("В этой локации сейчас нет врагов. Попробуйте позже."); + return ctx.answerCbQuery("В этой локации сейчас нет врагов. Попробуйте позже."); } const activeBattles = await Battle.findAll({ @@ -1659,14 +1647,14 @@ rpg.action(/hunt_location_\d+/, async (ctx) => { }); if (activeBattles.length === 0) { - return ctx.reply("В этой локации сейчас нет активных врагов. Попробуйте позже."); + return ctx.answerCbQuery("В этой локации сейчас нет активных врагов. Попробуйте позже."); } const activeEnemyIds = activeBattles.map((battle) => battle.enemy); const enemies = await Enemy.findAll({ where: { id: activeEnemyIds } }); if (enemies.length === 0) { - return ctx.reply("В этой локации сейчас нет врагов."); + return ctx.answerCbQuery("В этой локации сейчас нет врагов."); } const buttons = activeBattles.map((battle) => { @@ -1686,7 +1674,7 @@ rpg.action(/hunt_location_\d+/, async (ctx) => { const keyboard = Markup.inlineKeyboard(buttons.map((btn) => [btn])); - await ctx.reply( + await ctx.editMessageText( `🔍 Локация: ${location.name}\n\nВыберите врага для охоты:`, keyboard ); @@ -1749,7 +1737,7 @@ rpg.action(/use_grenade_\d+/, async (ctx) => { // Удаляем гранату из инвентаря await InventoryModel.destroy({ where: { id: grenade.id } }); - await ctx.reply(message); + await ctx.answerCbQuery(message, { show_alert: true }); }); @@ -1920,20 +1908,20 @@ function generateBattleButtons(character, battle) { // Генерация кнопки с критическим уроном buttons.push({ - text: `💥`, + text: `🎯`, callback_data: `critical_${battle.id}`, }); // Гарантированная кнопка промаха buttons.push({ - text: "❌", + text: "🎯", callback_data: `miss_${battle.id}`, }); // Заполнение оставшихся кнопок (если не хватает до totalButtons) while (buttons.length < totalButtons) { buttons.push({ - text: "❌", + text: "🎯", callback_data: `miss_${battle.id}`, }); } @@ -2055,40 +2043,4 @@ rpg.action(/miss_\d+/, async (ctx) => { -const fillItemsTable = async () => { - try { - const items = []; - - // Генерируем 10 случайных предметов - for (let i = 0; i < 10; i++) { - const item = { - name: fakerRU.commerce.productName(), // Название товара - description: fakerRU.lorem.sentence(), // Описание товара - price: fakerRU.commerce.price({ dec: 0 }), // Цена товара - rarity: 1, // Редкость (от 1 до 5) - type: 'other', // Тип предмета - }; - - items.push(item); - } - - // Вставляем все 10 предметов в таблицу - await ItemsModel.bulkCreate(items); - console.log('Таблица предметов успешно заполнена!'); - } catch (error) { - console.error('Ошибка при заполнении таблицы предметов:', error); - } -}; - -// Запускаем функцию -//fillItemsTable(); - - - - - - - - - module.exports = rpg; diff --git a/utils/logMiddleware.js b/utils/logMiddleware.js new file mode 100644 index 0000000..615e62d --- /dev/null +++ b/utils/logMiddleware.js @@ -0,0 +1,52 @@ +const fs = require("fs"); + +/** + * Middleware для логирования всех действий в боте. + */ +function logMiddleware(ctx, next) { + const logEntry = { + timestamp: new Date().toISOString(), + user: { + id: ctx.from?.id || "unknown", + username: ctx.from?.username || "unknown", + first_name: ctx.from?.first_name || "unknown", + last_name: ctx.from?.last_name || "", + }, + chat: ctx.chat ? { id: ctx.chat.id, type: ctx.chat.type } : null, + type: ctx.updateType, // Тип обновления (message, callback_query и т.д.) + data: getDataFromContext(ctx), // Извлечение данных из контекста + }; + + const logString = JSON.stringify(logEntry, null, 2); + + // Сохраняем лог в файл + fs.appendFile('./json/logs.json', logString + "\n", (err) => { + if (err) { + console.error("Ошибка при записи лога:", err); + } + }); + + // Вызываем следующий middleware + return next(); +} + +/** + * Извлечение данных из контекста (например, текст сообщения или данные кнопки). + */ +function getDataFromContext(ctx) { + if (ctx.message) { + return { text: ctx.message.text || "нет текста", message_id: ctx.message.message_id }; + } + + if (ctx.callbackQuery) { + return { data: ctx.callbackQuery.data || "нет данных", id: ctx.callbackQuery.id }; + } + + if (ctx.inlineQuery) { + return { query: ctx.inlineQuery.query || "пустой запрос" }; + } + + return "неизвестное событие"; +} + +module.exports = logMiddleware; diff --git a/utils/logs.js b/utils/logs.js new file mode 100644 index 0000000..f159049 --- /dev/null +++ b/utils/logs.js @@ -0,0 +1,34 @@ +const fs = require("fs"); +const path = require("path"); + +/** + * Функция для записи логов. + * @param {Object} ctx - Контекст Telegraf (содержит данные о пользователе и сообщении). + * @param {String} action - Описание действия, например, "Начало битвы", "Использована граната". + * @param {Object} [extraData] - Дополнительные данные для логов. + */ +function logAction(ctx, action, extraData = {}) { + const logEntry = { + timestamp: new Date().toISOString(), + user: { + id: ctx.from.id, + username: ctx.from.username || "unknown", + first_name: ctx.from.first_name || "unknown", + last_name: ctx.from.last_name || "", + }, + chat: ctx.chat ? { id: ctx.chat.id, type: ctx.chat.type } : null, + action, + extraData, + }; + + const logString = JSON.stringify(logEntry, null, 2); + + // Сохраняем лог в файл + fs.appendFile('./json/logs.json', logString + "\n", (err) => { + if (err) { + console.error("Ошибка при записи лога:", err); + } + }); +} + +module.exports = logAction;