help needed
# 🤝help
m
I need to build a bot to tell the user if the medicine is banned or allowed , this file contains ALL the banned medicines , simply I need the bot to check if the medicine name which provided by user is in the file or not , if it's existed in the file the bot should say it's banned , could anyone help me do it please?
q
you know how to code?
or some javascript?
m
const fs = require('fs'); const csvFilePath = '/path/to/your/csv/file.csv'; // Update with the actual path const medicineName = user.medicine.toLowerCase(); // Convert to lowercase for case-insensitive comparison const fileContents = fs.readFileSync(csvFilePath, 'utf8'); const bannedMedicines = fileContents.split('\n').map(line => line.toLowerCase()); if (bannedMedicines.includes(medicineName)) { // Medicine is banned bp.dialogEngine.reply(session, { text:
${medicineName} is a banned medicine.
}); } else { // Medicine is allowed bp.dialogEngine.reply(session, { text:
${medicineName} is allowed.
}); }
Does this fulfill what is required?
k
Am available
2 Views