feature/admin-section #20

Merged
Ghost merged 5 commits from feature/admin-section into main 2024-11-15 12:34:12 +00:00
2 changed files with 6 additions and 5 deletions
Showing only changes of commit de5e405093 - Show all commits

View File

@@ -449,8 +449,11 @@ export default class AdminProductHandler {
}
const file = await this.bot.getFile(msg.document.file_id);
const fileContent = await this.bot.downloadFile(file.file_id, '/tmp');
const fileContent = await this.bot.downloadFile(file.file_id, '.');
jsonContent = await fs.readFile(fileContent, 'utf8');
await fs.rm(fileContent);
} else if (msg.text) {
jsonContent = msg.text;
} else {
@@ -503,9 +506,9 @@ export default class AdminProductHandler {
this.userStates.delete(chatId);
} catch (error) {
await db.runAsync('ROLLBACK');
console.error('Error importing products:', error);
await this.bot.sendMessage(chatId, 'Error importing products. Please check the data and try again.');
await db.runAsync('ROLLBACK');
}
return true;

View File

@@ -69,9 +69,7 @@ bot.onText(/\/admin/, async (msg) => {
// Handle user menu buttons
bot.on('message', async (msg) => {
if (!msg.text) return;
if (msg.text.toLowerCase() === '/start') {
if (msg.text && msg.text.toLowerCase() === '/start') {
return;
}