stfca 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -22
- package/checkUpdate.js +43 -139
- package/index.js +11 -0
- package/package.json +3 -5
- package/CHANGELOG.md +0 -65
package/README.md
CHANGED
|
@@ -32,22 +32,49 @@ yarn add stfca
|
|
|
32
32
|
|
|
33
33
|
## 🔄 Auto-Update Feature
|
|
34
34
|
|
|
35
|
-
ST-FCA includes an automatic update
|
|
35
|
+
ST-FCA includes an **automatic update system** that keeps your package up-to-date seamlessly:
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
2. 💾 Creates automatic backups
|
|
39
|
-
3. 📦 Downloads and installs updates
|
|
40
|
-
4. 🔄 Restarts automatically to apply changes
|
|
37
|
+
### How It Works
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
1. 🔍 **Automatic Check**: Checks for updates when you start your bot
|
|
40
|
+
2. 📋 **Shows Changes**: Displays recent changelog updates
|
|
41
|
+
3. 📦 **NPM Update**: Runs `npm install stfca@latest` automatically
|
|
42
|
+
4. 🔄 **Auto-Restart**: Restarts your bot to apply changes
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
### For Bot Projects
|
|
45
|
+
|
|
46
|
+
If you're using ST-FCA in your bot project (like [ST-BOT](https://github.com/sheikhtamimlover/ST-BOT)), the package will:
|
|
47
|
+
|
|
48
|
+
- ✅ Detect when a new version is available
|
|
49
|
+
- ✅ Automatically update to the latest version via npm
|
|
50
|
+
- ✅ Update your `node_modules/stfca` folder
|
|
51
|
+
- ✅ Restart your bot with the new version
|
|
52
|
+
|
|
53
|
+
### Manual Update
|
|
54
|
+
|
|
55
|
+
You can also update manually:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install stfca@latest
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or check for updates programmatically:
|
|
45
62
|
|
|
46
63
|
```javascript
|
|
47
64
|
const { checkForFCAUpdate } = require('stfca/checkUpdate.js');
|
|
48
65
|
await checkForFCAUpdate();
|
|
49
66
|
```
|
|
50
67
|
|
|
68
|
+
### Update Notifications
|
|
69
|
+
|
|
70
|
+
The auto-update system will:
|
|
71
|
+
- Show the current and latest versions
|
|
72
|
+
- Display recent changes from the changelog
|
|
73
|
+
- Inform you when the update is complete
|
|
74
|
+
- Automatically restart your application
|
|
75
|
+
|
|
76
|
+
**Note**: Updates are non-blocking and won't interrupt your bot's startup if the update check fails.
|
|
77
|
+
|
|
51
78
|
## ⚠️ Important Disclaimer
|
|
52
79
|
|
|
53
80
|
**We are not responsible if your account gets banned for spammy activities such as:**
|
|
@@ -279,21 +306,13 @@ api.setOptions({
|
|
|
279
306
|
|
|
280
307
|
## 🛠️ Projects Using This API
|
|
281
308
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
- **[
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
-
|
|
289
|
-
- **[matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook)** - Facebook bridge for Matrix
|
|
290
|
-
- **[Miscord](https://github.com/Bjornskjald/miscord)** - Easy-to-use Facebook bridge for Discord
|
|
291
|
-
- **[chat-bridge](https://github.com/rexx0520/chat-bridge)** - Messenger, Telegram and IRC chat bridge
|
|
292
|
-
- **[Botium](https://github.com/codeforequity-at/botium-core)** - The Selenium for Chatbots
|
|
293
|
-
- **[Messenger-CLI](https://github.com/AstroCB/Messenger-CLI)** - Command-line interface for Facebook Messenger
|
|
294
|
-
- **[BotCore](https://github.com/AstroCB/BotCore)** - Tools for writing and managing Facebook Messenger bots
|
|
295
|
-
|
|
296
|
-
[See more projects...](https://github.com/Donix-VN/fca-unofficial#projects-using-this-api)
|
|
309
|
+
### Primary Project
|
|
310
|
+
|
|
311
|
+
- **[ST-BOT](https://github.com/sheikhtamimlover/ST-BOT)** - Enhanced version of GoatBot V2, a powerful and customizable Facebook Messenger bot with advanced features, plugin support, and automatic updates. This is the main project that ST-FCA was designed for.
|
|
312
|
+
|
|
313
|
+
### Other Use Cases
|
|
314
|
+
|
|
315
|
+
ST-FCA can be used for any Facebook Messenger bot project or automation tool. If you want to create your own messenger bot or use this API for other purposes, feel free to integrate it into your project.
|
|
297
316
|
|
|
298
317
|
## 📚 Full API Documentation
|
|
299
318
|
|
package/checkUpdate.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
const axios = require('axios');
|
|
3
2
|
const { execSync } = require('child_process');
|
|
4
3
|
const fs = require('fs');
|
|
@@ -8,24 +7,24 @@ async function checkForFCAUpdate() {
|
|
|
8
7
|
try {
|
|
9
8
|
console.log('\x1b[33m%s\x1b[0m', '🔍 Checking for ST-FCA updates...');
|
|
10
9
|
|
|
11
|
-
// Get latest version from
|
|
12
|
-
const { data:
|
|
13
|
-
'https://
|
|
10
|
+
// Get latest version from npm registry
|
|
11
|
+
const { data: npmData } = await axios.get(
|
|
12
|
+
'https://registry.npmjs.org/stfca/latest'
|
|
14
13
|
);
|
|
15
14
|
|
|
16
|
-
const latestVersion =
|
|
17
|
-
const currentPackagePath = path.join(__dirname, 'package.json');
|
|
15
|
+
const latestVersion = npmData.version;
|
|
18
16
|
|
|
19
|
-
// Check
|
|
20
|
-
let currentVersion = '1.0.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// Check current installed version in node_modules
|
|
18
|
+
let currentVersion = '1.0.8';
|
|
19
|
+
const nodeModulesPackagePath = path.join(process.cwd(), 'node_modules', 'stfca', 'package.json');
|
|
20
|
+
if (fs.existsSync(nodeModulesPackagePath)) {
|
|
21
|
+
const installedPackage = JSON.parse(fs.readFileSync(nodeModulesPackagePath, 'utf-8'));
|
|
22
|
+
currentVersion = installedPackage.version;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (latestVersion !== currentVersion) {
|
|
27
26
|
console.log('\x1b[32m%s\x1b[0m', `✨ New ST-FCA version available: ${latestVersion} (current: ${currentVersion})`);
|
|
28
|
-
console.log('\x1b[33m%s\x1b[0m', '📦 Updating ST-FCA...');
|
|
27
|
+
console.log('\x1b[33m%s\x1b[0m', '📦 Updating ST-FCA package...');
|
|
29
28
|
|
|
30
29
|
// Show changelog
|
|
31
30
|
try {
|
|
@@ -41,15 +40,18 @@ async function checkForFCAUpdate() {
|
|
|
41
40
|
// Silently ignore changelog fetch errors
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
//
|
|
45
|
-
await
|
|
43
|
+
// Update npm package
|
|
44
|
+
await updateNpmPackage(latestVersion);
|
|
45
|
+
|
|
46
|
+
// Update version in user's package.json
|
|
47
|
+
await updateUserPackageJson(latestVersion);
|
|
46
48
|
|
|
47
49
|
console.log('\x1b[32m%s\x1b[0m', '✅ ST-FCA updated successfully!');
|
|
48
50
|
console.log('\x1b[33m%s\x1b[0m', '🔄 Restarting to apply changes...');
|
|
49
51
|
|
|
50
52
|
// Restart the process
|
|
51
53
|
setTimeout(() => {
|
|
52
|
-
process.exit(
|
|
54
|
+
process.exit(2);
|
|
53
55
|
}, 1000);
|
|
54
56
|
|
|
55
57
|
return true;
|
|
@@ -63,146 +65,48 @@ async function checkForFCAUpdate() {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
async function
|
|
68
|
+
async function updateNpmPackage(version) {
|
|
67
69
|
try {
|
|
68
|
-
|
|
69
|
-
console.log('\x1b[36m%s\x1b[0m', '📂 Fetching complete file structure...');
|
|
70
|
-
const fileTree = await getGitHubFileTree();
|
|
70
|
+
console.log('\x1b[36m%s\x1b[0m', `📦 Running npm install stfca@${version}...`);
|
|
71
71
|
|
|
72
|
-
//
|
|
73
|
-
|
|
72
|
+
// Execute npm install command
|
|
73
|
+
execSync(`npm install stfca@${version} --save`, {
|
|
74
|
+
cwd: process.cwd(),
|
|
75
|
+
stdio: 'inherit'
|
|
76
|
+
});
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for (const file of fileTree) {
|
|
78
|
-
await downloadFile(file);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Step 4: Delete files that don't exist in the latest version
|
|
82
|
-
console.log('\x1b[36m%s\x1b[0m', '🗑️ Cleaning up old files...');
|
|
83
|
-
const githubFilePaths = fileTree.map(f => f.path);
|
|
84
|
-
for (const localFile of localFiles) {
|
|
85
|
-
if (!githubFilePaths.includes(localFile) && !shouldKeepFile(localFile)) {
|
|
86
|
-
deleteLocalFile(localFile);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log('\x1b[32m%s\x1b[0m', '✅ All files synchronized!');
|
|
78
|
+
console.log('\x1b[32m%s\x1b[0m', '✅ Package installed successfully!');
|
|
79
|
+
return true;
|
|
91
80
|
} catch (error) {
|
|
92
|
-
console.log('\x1b[31m%s\x1b[0m', '❌
|
|
81
|
+
console.log('\x1b[31m%s\x1b[0m', '❌ Failed to install package:', error.message);
|
|
93
82
|
throw error;
|
|
94
83
|
}
|
|
95
84
|
}
|
|
96
85
|
|
|
97
|
-
async function
|
|
86
|
+
async function updateUserPackageJson(version) {
|
|
98
87
|
try {
|
|
99
|
-
const
|
|
100
|
-
'https://api.github.com/repos/sheikhtamimlover/ST-FCA/git/trees/main?recursive=1'
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
// Filter only files (not directories)
|
|
104
|
-
return data.tree
|
|
105
|
-
.filter(item => item.type === 'blob')
|
|
106
|
-
.filter(item => !item.path.startsWith('.git'))
|
|
107
|
-
.filter(item => !shouldIgnoreFile(item.path));
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.log('\x1b[31m%s\x1b[0m', '❌ Failed to fetch file tree:', error.message);
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
88
|
+
const userPackageJsonPath = path.join(process.cwd(), 'package.json');
|
|
113
89
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function walkDir(dir, baseDir = '') {
|
|
118
|
-
const items = fs.readdirSync(dir);
|
|
119
|
-
|
|
120
|
-
for (const item of items) {
|
|
121
|
-
const fullPath = path.join(dir, item);
|
|
122
|
-
const relativePath = baseDir ? path.join(baseDir, item) : item;
|
|
123
|
-
|
|
124
|
-
if (shouldIgnoreFile(relativePath)) continue;
|
|
125
|
-
|
|
126
|
-
const stat = fs.statSync(fullPath);
|
|
127
|
-
|
|
128
|
-
if (stat.isDirectory()) {
|
|
129
|
-
walkDir(fullPath, relativePath);
|
|
130
|
-
} else {
|
|
131
|
-
files.push(relativePath.replace(/\\/g, '/'));
|
|
132
|
-
}
|
|
90
|
+
if (!fs.existsSync(userPackageJsonPath)) {
|
|
91
|
+
console.log('\x1b[33m%s\x1b[0m', '⚠️ No package.json found in user project');
|
|
92
|
+
return;
|
|
133
93
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
walkDir(__dirname);
|
|
137
|
-
return files;
|
|
138
|
-
}
|
|
139
94
|
|
|
140
|
-
|
|
141
|
-
const ignorePatterns = [
|
|
142
|
-
'node_modules',
|
|
143
|
-
'.git',
|
|
144
|
-
'.env',
|
|
145
|
-
'appstate.json',
|
|
146
|
-
'fbstate.json',
|
|
147
|
-
'package-lock.json',
|
|
148
|
-
'.replit',
|
|
149
|
-
'replit.nix',
|
|
150
|
-
'.config',
|
|
151
|
-
'generated-icon.png'
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
return ignorePatterns.some(pattern => filePath.includes(pattern));
|
|
155
|
-
}
|
|
95
|
+
const packageJson = JSON.parse(fs.readFileSync(userPackageJsonPath, 'utf-8'));
|
|
156
96
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
'fbstate.json',
|
|
163
|
-
'package-lock.json',
|
|
164
|
-
'.replit',
|
|
165
|
-
'replit.nix',
|
|
166
|
-
'.config'
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
return keepPatterns.some(pattern => filePath.includes(pattern));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
async function downloadFile(fileInfo) {
|
|
173
|
-
try {
|
|
174
|
-
const targetPath = path.join(__dirname, fileInfo.path);
|
|
175
|
-
|
|
176
|
-
// Download file content
|
|
177
|
-
const { data } = await axios.get(
|
|
178
|
-
`https://raw.githubusercontent.com/sheikhtamimlover/ST-FCA/main/${fileInfo.path}`,
|
|
179
|
-
{ responseType: 'arraybuffer' }
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
// Ensure directory exists
|
|
183
|
-
const fileDir = path.dirname(targetPath);
|
|
184
|
-
if (!fs.existsSync(fileDir)) {
|
|
185
|
-
fs.mkdirSync(fileDir, { recursive: true });
|
|
97
|
+
// Update stfca version in dependencies
|
|
98
|
+
if (packageJson.dependencies && packageJson.dependencies.stfca) {
|
|
99
|
+
packageJson.dependencies.stfca = `^${version}`;
|
|
100
|
+
fs.writeFileSync(userPackageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
101
|
+
console.log('\x1b[32m%s\x1b[0m', `✅ Updated package.json to stfca@${version}`);
|
|
186
102
|
}
|
|
187
|
-
|
|
188
|
-
// Write file
|
|
189
|
-
fs.writeFileSync(targetPath, Buffer.from(data));
|
|
190
|
-
console.log('\x1b[32m%s\x1b[0m', ` ✓ ${fileInfo.path}`);
|
|
191
|
-
} catch (error) {
|
|
192
|
-
console.log('\x1b[31m%s\x1b[0m', ` ✗ Failed: ${fileInfo.path}`, error.message);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
103
|
|
|
196
|
-
|
|
197
|
-
try {
|
|
198
|
-
const fullPath = path.join(__dirname, filePath);
|
|
199
|
-
if (fs.existsSync(fullPath)) {
|
|
200
|
-
fs.unlinkSync(fullPath);
|
|
201
|
-
console.log('\x1b[33m%s\x1b[0m', ` 🗑️ Deleted: ${filePath}`);
|
|
202
|
-
}
|
|
104
|
+
return true;
|
|
203
105
|
} catch (error) {
|
|
204
|
-
console.log('\x1b[31m%s\x1b[0m',
|
|
106
|
+
console.log('\x1b[31m%s\x1b[0m', '⚠️ Failed to update user package.json:', error.message);
|
|
107
|
+
// Don't throw - this is not critical
|
|
108
|
+
return false;
|
|
205
109
|
}
|
|
206
110
|
}
|
|
207
111
|
|
|
208
|
-
module.exports = { checkForFCAUpdate,
|
|
112
|
+
module.exports = { checkForFCAUpdate, updateNpmPackage, updateUserPackageJson };
|
package/index.js
CHANGED
|
@@ -13,6 +13,17 @@ const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence'
|
|
|
13
13
|
global.ditconmemay = false;
|
|
14
14
|
global.stfcaUpdateChecked = false;
|
|
15
15
|
|
|
16
|
+
// Auto-check for updates on package load (non-blocking)
|
|
17
|
+
if (!global.stfcaUpdateChecked) {
|
|
18
|
+
global.stfcaUpdateChecked = true;
|
|
19
|
+
const { checkForFCAUpdate } = require("./checkUpdate");
|
|
20
|
+
setImmediate(() => {
|
|
21
|
+
checkForFCAUpdate().catch(() => {
|
|
22
|
+
// Silent fail - don't interrupt user's bot
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
function setOptions(globalOptions, options) {
|
|
17
28
|
Object.keys(options).map(function (key) {
|
|
18
29
|
switch (Boolean_Option.includes(key)) {
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stfca",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Unofficial Facebook Chat API for Node.js - Enhanced by ST | Sheikh Tamim",
|
|
3
|
+
"version": "1.0.10",
|
|
4
|
+
"description": "Unofficial Facebook Chat API for Node.js with Auto-Update System - Enhanced by ST | Sheikh Tamim",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/",
|
|
8
8
|
"index.js",
|
|
9
9
|
"utils.js",
|
|
10
|
-
"checkUpdate.js"
|
|
11
|
-
"README.md",
|
|
12
|
-
"CHANGELOG.md"
|
|
10
|
+
"checkUpdate.js"
|
|
13
11
|
],
|
|
14
12
|
"scripts": {
|
|
15
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/CHANGELOG.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Changelog
|
|
3
|
-
|
|
4
|
-
All notable changes to ST-FCA will be documented in this file.
|
|
5
|
-
|
|
6
|
-
## [1.0.5] - 2025-01-13
|
|
7
|
-
|
|
8
|
-
### Added
|
|
9
|
-
- 🔄 Comprehensive update system that properly syncs all files
|
|
10
|
-
- 📂 Automatic file tree comparison between local and GitHub
|
|
11
|
-
- ➕ Smart file addition for new files in updates
|
|
12
|
-
- ♻️ Automatic modification detection and update
|
|
13
|
-
- 🗑️ Automatic deletion of removed files from old versions
|
|
14
|
-
- 🎯 No backup folder creation - cleaner updates
|
|
15
|
-
|
|
16
|
-
### Changed
|
|
17
|
-
- Improved update mechanism to handle version jumps (e.g., 1.0.3 → 1.0.6)
|
|
18
|
-
- Enhanced file synchronization to ensure no missing files
|
|
19
|
-
- Better error handling during updates
|
|
20
|
-
- Auto-restart after successful update
|
|
21
|
-
|
|
22
|
-
### Fixed
|
|
23
|
-
- Missing files when updating across multiple versions
|
|
24
|
-
- Outdated files not being properly replaced
|
|
25
|
-
- Orphaned files from old versions not being cleaned up
|
|
26
|
-
|
|
27
|
-
## [1.0.4] - 2025-01-13
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- 🔄 Automatic update checking on package initialization
|
|
31
|
-
- ⚡ Non-blocking update process - doesn't interrupt user's bot startup
|
|
32
|
-
- 🎯 Update check runs once per session to avoid redundant checks
|
|
33
|
-
- 💡 Silent error handling for update checks
|
|
34
|
-
|
|
35
|
-
### Changed
|
|
36
|
-
- Update checker now integrated directly into login flow
|
|
37
|
-
- Improved user experience with seamless auto-updates
|
|
38
|
-
|
|
39
|
-
## [1.0.3] - 2025-01-13
|
|
40
|
-
|
|
41
|
-
### Added
|
|
42
|
-
- 🎨 Enhanced MQTT connection logging with visual indicators
|
|
43
|
-
- 🔄 Auto-reconnect status display
|
|
44
|
-
- 📊 Connection region display
|
|
45
|
-
- ⚡ Automatic update checking and installation
|
|
46
|
-
- 💾 Automatic backup creation before updates
|
|
47
|
-
- 🎯 Better error messages and debugging
|
|
48
|
-
- 📋 Changelog tracking
|
|
49
|
-
- 🌟 Branding: "Maintained & Enhanced by ST | Sheikh Tamim"
|
|
50
|
-
|
|
51
|
-
### Changed
|
|
52
|
-
- Improved console output with colors and formatting
|
|
53
|
-
- Better connection status messages
|
|
54
|
-
- Enhanced stability and error handling
|
|
55
|
-
|
|
56
|
-
### Fixed
|
|
57
|
-
- MQTT reconnection reliability
|
|
58
|
-
- Connection timeout handling
|
|
59
|
-
- Error message clarity
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
**Maintained & Enhanced by ST | Sheikh Tamim**
|
|
64
|
-
GitHub: https://github.com/sheikhtamimlover/ST-FCA
|
|
65
|
-
NPM: https://www.npmjs.com/package/stfca
|