import from json
This commit is contained in:
parent
4251f1a0bd
commit
de5e405093
@ -449,8 +449,11 @@ export default class AdminProductHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const file = await this.bot.getFile(msg.document.file_id);
|
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');
|
jsonContent = await fs.readFile(fileContent, 'utf8');
|
||||||
|
await fs.rm(fileContent);
|
||||||
|
|
||||||
} else if (msg.text) {
|
} else if (msg.text) {
|
||||||
jsonContent = msg.text;
|
jsonContent = msg.text;
|
||||||
} else {
|
} else {
|
||||||
@ -503,9 +506,9 @@ export default class AdminProductHandler {
|
|||||||
|
|
||||||
this.userStates.delete(chatId);
|
this.userStates.delete(chatId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await db.runAsync('ROLLBACK');
|
|
||||||
console.error('Error importing products:', error);
|
console.error('Error importing products:', error);
|
||||||
await this.bot.sendMessage(chatId, 'Error importing products. Please check the data and try again.');
|
await this.bot.sendMessage(chatId, 'Error importing products. Please check the data and try again.');
|
||||||
|
await db.runAsync('ROLLBACK');
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -69,9 +69,7 @@ bot.onText(/\/admin/, async (msg) => {
|
|||||||
|
|
||||||
// Handle user menu buttons
|
// Handle user menu buttons
|
||||||
bot.on('message', async (msg) => {
|
bot.on('message', async (msg) => {
|
||||||
if (!msg.text) return;
|
if (msg.text && msg.text.toLowerCase() === '/start') {
|
||||||
|
|
||||||
if (msg.text.toLowerCase() === '/start') {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user