Upload 3 files
Browse files- Dockerfile +28 -0
- index.js +23 -0
- package.json +16 -0
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:18-slim
|
| 2 |
+
|
| 3 |
+
# 1. تثبيت المتصفح والخطوط العربية
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
chromium \
|
| 6 |
+
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
|
| 7 |
+
--no-install-recommends \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# 2. إعداد مجلد التطبيق
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# 3. نسخ ملفات التعريف وتثبيت المكاتب
|
| 14 |
+
COPY package*.json ./
|
| 15 |
+
RUN npm install
|
| 16 |
+
|
| 17 |
+
# 4. نسخ باقي الكود
|
| 18 |
+
COPY . .
|
| 19 |
+
|
| 20 |
+
# 5. صلاحيات المستخدم (للأمان)
|
| 21 |
+
RUN chown -R node:node /app
|
| 22 |
+
USER node
|
| 23 |
+
|
| 24 |
+
# 6. المنفذ
|
| 25 |
+
EXPOSE 7860
|
| 26 |
+
|
| 27 |
+
# 7. التشغيل
|
| 28 |
+
CMD [ "node", "index.js" ]
|
index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const { qrStream } = require('./src/bot_controller');
|
| 3 |
+
|
| 4 |
+
const app = express();
|
| 5 |
+
const port = 7860; // منفذ Hugging Face
|
| 6 |
+
|
| 7 |
+
app.get('/', (req, res) => {
|
| 8 |
+
if (qrStream.data === "CONNECTED") {
|
| 9 |
+
res.send('<h1 style="color:green;text-align:center;margin-top:20%;">✅ Bot is Connected & Running!</h1>');
|
| 10 |
+
} else if (qrStream.data) {
|
| 11 |
+
res.send(`
|
| 12 |
+
<div style="text-align:center;margin-top:50px;">
|
| 13 |
+
<h1>Scan this QR Code</h1>
|
| 14 |
+
<img src="${qrStream.data}" style="width:300px;"/>
|
| 15 |
+
<p>Refresh page if code expired.</p>
|
| 16 |
+
</div>
|
| 17 |
+
`);
|
| 18 |
+
} else {
|
| 19 |
+
res.send('<h1 style="text-align:center;">Initializing... Wait 10 seconds and Refresh 🔄</h1>');
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
app.listen(port, () => console.log(`Server running on port ${port}`));
|
package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "morocco-hunter-bot",
|
| 3 |
+
"version": "2.0.0",
|
| 4 |
+
"main": "index.js",
|
| 5 |
+
"scripts": {
|
| 6 |
+
"start": "node index.js"
|
| 7 |
+
},
|
| 8 |
+
"dependencies": {
|
| 9 |
+
"whatsapp-web.js": "^1.23.0",
|
| 10 |
+
"qrcode": "^1.5.3",
|
| 11 |
+
"express": "^4.18.2",
|
| 12 |
+
"@huggingface/inference": "^2.6.4",
|
| 13 |
+
"duck-duck-scrape": "^2.2.4",
|
| 14 |
+
"dotenv": "^16.3.1"
|
| 15 |
+
}
|
| 16 |
+
}
|