stfca 1.0.9 → 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.
Files changed (3) hide show
  1. package/README.md +7 -15
  2. package/checkUpdate.js +23 -137
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -306,21 +306,13 @@ api.setOptions({
306
306
 
307
307
  ## 🛠️ Projects Using This API
308
308
 
309
- - **[c3c](https://github.com/lequanglam/c3c)** - Customizable bot with plugins, supports Facebook & Discord
310
- - **[Miraiv2](https://github.com/miraiPr0ject/miraiv2)** - Simple Facebook Messenger Bot
311
- - **[Messer](https://github.com/mjkaufer/Messer)** - Command-line messaging for Facebook Messenger
312
- - **[messen](https://github.com/tomquirk/messen)** - Rapidly build Facebook Messenger apps in Node.js
313
- - **[Concierge](https://github.com/concierge/Concierge)** - Highly modular chat bot with built-in package manager
314
- - **[Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot)** - Facebook chat bot
315
- - **[Botyo](https://github.com/ivkos/botyo)** - Modular bot for group chat rooms
316
- - **[matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook)** - Facebook bridge for Matrix
317
- - **[Miscord](https://github.com/Bjornskjald/miscord)** - Easy-to-use Facebook bridge for Discord
318
- - **[chat-bridge](https://github.com/rexx0520/chat-bridge)** - Messenger, Telegram and IRC chat bridge
319
- - **[Botium](https://github.com/codeforequity-at/botium-core)** - The Selenium for Chatbots
320
- - **[Messenger-CLI](https://github.com/AstroCB/Messenger-CLI)** - Command-line interface for Facebook Messenger
321
- - **[BotCore](https://github.com/AstroCB/BotCore)** - Tools for writing and managing Facebook Messenger bots
322
-
323
- [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.
324
316
 
325
317
  ## 📚 Full API Documentation
326
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');
@@ -44,6 +43,9 @@ async function checkForFCAUpdate() {
44
43
  // Update npm package
45
44
  await updateNpmPackage(latestVersion);
46
45
 
46
+ // Update version in user's package.json
47
+ await updateUserPackageJson(latestVersion);
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
 
@@ -65,162 +67,46 @@ async function checkForFCAUpdate() {
65
67
 
66
68
  async function updateNpmPackage(version) {
67
69
  try {
68
- console.log('\x1b[36m%s\x1b[0m', '📦 Running npm install stfca@latest...');
70
+ console.log('\x1b[36m%s\x1b[0m', `📦 Running npm install stfca@${version}...`);
69
71
 
70
72
  // Execute npm install command
71
- execSync('npm install stfca@latest --save', {
73
+ execSync(`npm install stfca@${version} --save`, {
72
74
  cwd: process.cwd(),
73
75
  stdio: 'inherit'
74
76
  });
75
77
 
76
- console.log('\x1b[32m%s\x1b[0m', '✅ Package updated successfully!');
78
+ console.log('\x1b[32m%s\x1b[0m', '✅ Package installed successfully!');
77
79
  return true;
78
80
  } catch (error) {
79
- console.log('\x1b[31m%s\x1b[0m', '❌ Failed to update package:', error.message);
80
- throw error;
81
- }
82
- }
83
-
84
- async function performComprehensiveUpdate() {
85
- try {
86
- // Step 1: Get the complete file tree from GitHub
87
- console.log('\x1b[36m%s\x1b[0m', '📂 Fetching complete file structure...');
88
- const fileTree = await getGitHubFileTree();
89
-
90
- // Step 2: Get local files
91
- const localFiles = getLocalFiles();
92
-
93
- // Step 3: Download/Update all files from GitHub
94
- console.log('\x1b[36m%s\x1b[0m', '⬇️ Downloading files...');
95
- for (const file of fileTree) {
96
- await downloadFile(file);
97
- }
98
-
99
- // Step 4: Delete files that don't exist in the latest version
100
- console.log('\x1b[36m%s\x1b[0m', '🗑️ Cleaning up old files...');
101
- const githubFilePaths = fileTree.map(f => f.path);
102
- for (const localFile of localFiles) {
103
- if (!githubFilePaths.includes(localFile) && !shouldKeepFile(localFile)) {
104
- deleteLocalFile(localFile);
105
- }
106
- }
107
-
108
- console.log('\x1b[32m%s\x1b[0m', '✅ All files synchronized!');
109
- } catch (error) {
110
- console.log('\x1b[31m%s\x1b[0m', '❌ Update failed:', error.message);
81
+ console.log('\x1b[31m%s\x1b[0m', '❌ Failed to install package:', error.message);
111
82
  throw error;
112
83
  }
113
84
  }
114
85
 
115
- async function getGitHubFileTree() {
86
+ async function updateUserPackageJson(version) {
116
87
  try {
117
- const { data } = await axios.get(
118
- 'https://api.github.com/repos/sheikhtamimlover/ST-FCA/git/trees/main?recursive=1'
119
- );
120
-
121
- // Filter only files (not directories)
122
- return data.tree
123
- .filter(item => item.type === 'blob')
124
- .filter(item => !item.path.startsWith('.git'))
125
- .filter(item => !shouldIgnoreFile(item.path));
126
- } catch (error) {
127
- console.log('\x1b[31m%s\x1b[0m', '❌ Failed to fetch file tree:', error.message);
128
- throw error;
129
- }
130
- }
88
+ const userPackageJsonPath = path.join(process.cwd(), 'package.json');
131
89
 
132
- function getLocalFiles() {
133
- const files = [];
134
-
135
- function walkDir(dir, baseDir = '') {
136
- const items = fs.readdirSync(dir);
137
-
138
- for (const item of items) {
139
- const fullPath = path.join(dir, item);
140
- const relativePath = baseDir ? path.join(baseDir, item) : item;
141
-
142
- if (shouldIgnoreFile(relativePath)) continue;
143
-
144
- const stat = fs.statSync(fullPath);
145
-
146
- if (stat.isDirectory()) {
147
- walkDir(fullPath, relativePath);
148
- } else {
149
- files.push(relativePath.replace(/\\/g, '/'));
150
- }
90
+ if (!fs.existsSync(userPackageJsonPath)) {
91
+ console.log('\x1b[33m%s\x1b[0m', '⚠️ No package.json found in user project');
92
+ return;
151
93
  }
152
- }
153
-
154
- walkDir(__dirname);
155
- return files;
156
- }
157
94
 
158
- function shouldIgnoreFile(filePath) {
159
- const ignorePatterns = [
160
- 'node_modules',
161
- '.git',
162
- '.env',
163
- 'appstate.json',
164
- 'fbstate.json',
165
- 'package-lock.json',
166
- '.replit',
167
- 'replit.nix',
168
- '.config',
169
- 'generated-icon.png'
170
- ];
171
-
172
- return ignorePatterns.some(pattern => filePath.includes(pattern));
173
- }
174
-
175
- function shouldKeepFile(filePath) {
176
- const keepPatterns = [
177
- 'node_modules',
178
- '.env',
179
- 'appstate.json',
180
- 'fbstate.json',
181
- 'package-lock.json',
182
- '.replit',
183
- 'replit.nix',
184
- '.config'
185
- ];
186
-
187
- return keepPatterns.some(pattern => filePath.includes(pattern));
188
- }
95
+ const packageJson = JSON.parse(fs.readFileSync(userPackageJsonPath, 'utf-8'));
189
96
 
190
- async function downloadFile(fileInfo) {
191
- try {
192
- const targetPath = path.join(__dirname, fileInfo.path);
193
-
194
- // Download file content
195
- const { data } = await axios.get(
196
- `https://raw.githubusercontent.com/sheikhtamimlover/ST-FCA/main/${fileInfo.path}`,
197
- { responseType: 'arraybuffer' }
198
- );
199
-
200
- // Ensure directory exists
201
- const fileDir = path.dirname(targetPath);
202
- if (!fs.existsSync(fileDir)) {
203
- 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}`);
204
102
  }
205
-
206
- // Write file
207
- fs.writeFileSync(targetPath, Buffer.from(data));
208
- console.log('\x1b[32m%s\x1b[0m', ` ✓ ${fileInfo.path}`);
209
- } catch (error) {
210
- console.log('\x1b[31m%s\x1b[0m', ` ✗ Failed: ${fileInfo.path}`, error.message);
211
- }
212
- }
213
103
 
214
- function deleteLocalFile(filePath) {
215
- try {
216
- const fullPath = path.join(__dirname, filePath);
217
- if (fs.existsSync(fullPath)) {
218
- fs.unlinkSync(fullPath);
219
- console.log('\x1b[33m%s\x1b[0m', ` 🗑️ Deleted: ${filePath}`);
220
- }
104
+ return true;
221
105
  } catch (error) {
222
- console.log('\x1b[31m%s\x1b[0m', ` Failed to delete: ${filePath}`, error.message);
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;
223
109
  }
224
110
  }
225
111
 
226
- module.exports = { checkForFCAUpdate, performComprehensiveUpdate, updateNpmPackage };
112
+ module.exports = { checkForFCAUpdate, updateNpmPackage, updateUserPackageJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stfca",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
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": [