Alexainc commited on
Commit ·
fbd091f
1
Parent(s): 7cdf82a
Fix: Align environment with working wordsolvebot (Node 18, Telegraf 4.16.3)
Browse files- Dockerfile +1 -1
- bot.js +1 -14
- package.json +2 -2
Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
FROM node:
|
| 2 |
|
| 3 |
# Install dependencies for Tesseract.js (if needed by sharp or other system libs)
|
| 4 |
# and Python for easyocr
|
|
|
|
| 1 |
+
FROM node:18
|
| 2 |
|
| 3 |
# Install dependencies for Tesseract.js (if needed by sharp or other system libs)
|
| 4 |
# and Python for easyocr
|
bot.js
CHANGED
|
@@ -4,8 +4,6 @@ const fs = require('fs');
|
|
| 4 |
const path = require('path');
|
| 5 |
const { finished } = require('stream/promises');
|
| 6 |
const express = require('express');
|
| 7 |
-
const https = require('https');
|
| 8 |
-
|
| 9 |
const { extractGrid } = require('./ocr');
|
| 10 |
const { solve } = require('./solver');
|
| 11 |
require('dotenv').config();
|
|
@@ -41,13 +39,6 @@ if (!BOT_TOKEN) {
|
|
| 41 |
console.error('BOT_TOKEN is required in process.env.BOT_TOKEN');
|
| 42 |
}
|
| 43 |
|
| 44 |
-
// Custom HTTPS Agent to handle network issues in environments like Hugging Face
|
| 45 |
-
const httpsAgent = new https.Agent({
|
| 46 |
-
keepAlive: true,
|
| 47 |
-
family: 4, // Force IPv4 to avoid weird DNS/IPv6 issues in some cloud environments
|
| 48 |
-
timeout: 30000 // 30 second timeout
|
| 49 |
-
});
|
| 50 |
-
|
| 51 |
// Windows EPERM Fix: Retry-based file deletion
|
| 52 |
async function deleteFileWithRetry(filePath, retries = 5, delay = 1000) {
|
| 53 |
for (let i = 0; i < retries; i++) {
|
|
@@ -63,11 +54,7 @@ async function deleteFileWithRetry(filePath, retries = 5, delay = 1000) {
|
|
| 63 |
}
|
| 64 |
}
|
| 65 |
|
| 66 |
-
const bot = new Telegraf(BOT_TOKEN || 'DUMMY_TOKEN'
|
| 67 |
-
telegram: {
|
| 68 |
-
agent: httpsAgent
|
| 69 |
-
}
|
| 70 |
-
});
|
| 71 |
|
| 72 |
|
| 73 |
bot.start((ctx) => ctx.reply('Send me a word grid image and the word patterns (e.g., M--- (4)) to solve it!'));
|
|
|
|
| 4 |
const path = require('path');
|
| 5 |
const { finished } = require('stream/promises');
|
| 6 |
const express = require('express');
|
|
|
|
|
|
|
| 7 |
const { extractGrid } = require('./ocr');
|
| 8 |
const { solve } = require('./solver');
|
| 9 |
require('dotenv').config();
|
|
|
|
| 39 |
console.error('BOT_TOKEN is required in process.env.BOT_TOKEN');
|
| 40 |
}
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
// Windows EPERM Fix: Retry-based file deletion
|
| 43 |
async function deleteFileWithRetry(filePath, retries = 5, delay = 1000) {
|
| 44 |
for (let i = 0; i < retries; i++) {
|
|
|
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
+
const bot = new Telegraf(BOT_TOKEN || 'DUMMY_TOKEN');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
bot.start((ctx) => ctx.reply('Send me a word grid image and the word patterns (e.g., M--- (4)) to solve it!'));
|
package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
| 13 |
"dotenv": "^17.4.2",
|
| 14 |
"express": "^5.2.1",
|
| 15 |
"sharp": "^0.34.5",
|
| 16 |
-
"telegraf": "^4.
|
| 17 |
"tesseract.js": "^5.0.0"
|
| 18 |
}
|
| 19 |
-
}
|
|
|
|
| 13 |
"dotenv": "^17.4.2",
|
| 14 |
"express": "^5.2.1",
|
| 15 |
"sharp": "^0.34.5",
|
| 16 |
+
"telegraf": "^4.16.3",
|
| 17 |
"tesseract.js": "^5.0.0"
|
| 18 |
}
|
| 19 |
+
}
|