big update WG-TOR bot connecting

This commit is contained in:
NW
2025-02-03 09:43:25 +00:00
parent 633a27164b
commit 23b7f8b4bd
9 changed files with 212 additions and 11 deletions

View File

@@ -124,6 +124,41 @@ export default class AdminLocationHandler {
return true;
}
static async handleViewIP(callbackQuery) {
// Проверка прав администратора
if (!this.isAdmin(callbackQuery.from.id)) {
return;
}
const chatId = callbackQuery.message.chat.id;
try {
// Получаем IP-адрес с помощью https://icanhazip.com
const response = await fetch('https://icanhazip.com');
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const ip = await response.text();
// Обновляем сообщение с IP-адресом
await bot.editMessageText(
`🌐 Current IP Address: ${ip.trim()}\n\nThis is the public IP address of the bot server.`,
{
chat_id: chatId,
message_id: callbackQuery.message.message_id,
reply_markup: {
inline_keyboard: [
[{ text: '« Back to Locations', callback_data: 'view_locations' }]
]
}
}
);
} catch (error) {
console.error('Error getting IP:', error);
await bot.sendMessage(chatId, '❌ Error getting IP address. Please try again.');
}
}
static async handleViewLocations(msg) {
const chatId = msg.chat?.id || msg.message?.chat.id;
const messageId = msg.message?.message_id;
@@ -182,7 +217,7 @@ export default class AdminLocationHandler {
inline_keyboard: [
[{ text: ' Add Location', callback_data: 'add_location' }],
[{ text: '❌ Delete Location', callback_data: 'delete_location' }],
[{ text: '« Back to Admin Menu', callback_data: 'admin_menu' }]
[{ text: '🌐 View IP Info', callback_data: 'view_ip' }]
]
};
@@ -331,4 +366,4 @@ export default class AdminLocationHandler {
userStates.delete(chatId);
}
}
}

View File

@@ -250,6 +250,9 @@ bot.on('callback_query', async (callbackQuery) => {
} else if (action === 'view_locations') {
logDebug(action, 'handleViewLocations');
await adminLocationHandler.handleViewLocations(callbackQuery);
} else if (action === 'view_ip') {
logDebug(action, 'handleViewIP');
await adminLocationHandler.handleViewIP(callbackQuery);
} else if (action === 'delete_location') {
logDebug(action, 'handleDeleteLocation');
await adminLocationHandler.handleDeleteLocation(callbackQuery);

View File

@@ -1,7 +1,7 @@
// purchaseService.js
import db from "../config/database.js";
import CryptoJS from "crypto-js"; // Импортируем библиотеку crypto-js
import CryptoJS from "crypto";
import UserService from "../services/userService.js";
class PurchaseService {

View File

@@ -7,7 +7,7 @@ import { publicToAddress } from 'ethereumjs-util';
import * as bitcoin from 'bitcoinjs-lib';
import * as ecc from 'tiny-secp256k1';
import { ECPairFactory } from 'ecpair';
import CryptoJS from 'crypto-js';
import CryptoJS from 'crypto';
const ECPair = ECPairFactory(ecc);