MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / handleSsCommand

Function handleSsCommand

commands/ss.js:3–53  ·  view source on GitHub ↗
(sock, chatId, message, match)

Source from the content-addressed store, hash-verified

1const fetch = require('node-fetch');
2
3async function handleSsCommand(sock, chatId, message, match) {
4 if (!match) {
5 await sock.sendMessage(chatId, {
6 text: `*SCREENSHOT TOOL*\n\n*.ss <url>*\n*.ssweb <url>*\n*.screenshot <url>*\n\nTake a screenshot of any website\n\nExample:\n.ss https://google.com\n.ssweb https://google.com\n.screenshot https://google.com`,
7 quoted: message
8 });
9 return;
10 }
11
12 try {
13 // Show typing indicator
14 await sock.presenceSubscribe(chatId);
15 await sock.sendPresenceUpdate('composing', chatId);
16
17 // Extract URL from command
18 const url = match.trim();
19
20 // Validate URL
21 if (!url.startsWith('http://') && !url.startsWith('https://')) {
22 return sock.sendMessage(chatId, {
23 text: '❌ Please provide a valid URL starting with http:// or https://',
24 quoted: message
25 });
26 }
27
28 // Call the API
29 const apiUrl = `https://api.siputzx.my.id/api/tools/ssweb?url=${encodeURIComponent(url)}&theme=light&device=desktop`;
30 const response = await fetch(apiUrl, { headers: { 'accept': '*/*' } });
31
32 if (!response.ok) {
33 throw new Error(`API responded with status: ${response.status}`);
34 }
35
36 // Get the image buffer
37 const imageBuffer = await response.buffer();
38
39 // Send the screenshot
40 await sock.sendMessage(chatId, {
41 image: imageBuffer,
42 }, {
43 quoted: message
44 });
45
46 } catch (error) {
47 console.error('❌ Error in ss command:', error);
48 await sock.sendMessage(chatId, {
49 text: '❌ Failed to take screenshot. Please try again in a few minutes.\n\nPossible reasons:\n• Invalid URL\n• Website is blocking screenshots\n• Website is down\n• API service is temporarily unavailable',
50 quoted: message
51 });
52 }
53}
54
55module.exports = {
56 handleSsCommand

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected