|
|
import * as dotenv from 'dotenv'; |
|
|
import { fetchDataFromTable } from './db/supabaseHelper'; |
|
|
|
|
|
dotenv.config(); |
|
|
|
|
|
export const config = { |
|
|
BOT_TOKEN: process.env.BOT_TOKEN || '', |
|
|
API_ID: parseInt(process.env.API_ID || ''), |
|
|
API_HASH: process.env.API_HASH || '', |
|
|
PHONE_NUMBER: process.env.PHONE_NUMBER || '', |
|
|
STRING_SESSION: process.env.STRING_SESSION || '', |
|
|
}; |
|
|
|
|
|
export const PORT = process.env.PORT || 7860; |
|
|
|
|
|
|
|
|
export let COMMANDS: Record<string, string> = { |
|
|
GO: ".", |
|
|
}; |
|
|
|
|
|
export let MESSAGES: Record<string, string> = { |
|
|
FORWARD_SUCCESS: "أتفضل", |
|
|
}; |
|
|
|
|
|
|
|
|
export const loadCommandsAndMessages = async () => { |
|
|
try { |
|
|
const commands = await fetchDataFromTable('commands', 1000,0); |
|
|
const messages = await fetchDataFromTable('messages', 1000,0); |
|
|
|
|
|
|
|
|
COMMANDS = {}; |
|
|
|
|
|
|
|
|
commands.forEach((cmd: any) => { |
|
|
COMMANDS[cmd.key] = cmd.key; |
|
|
}); |
|
|
|
|
|
|
|
|
MESSAGES = {}; |
|
|
|
|
|
|
|
|
messages.forEach((msg: any) => { |
|
|
MESSAGES[msg.key] = msg.value; |
|
|
}); |
|
|
|
|
|
console.log('Commands and messages loaded from database'); |
|
|
} catch (error) { |
|
|
console.error('Error loading commands and messages:', error); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|