cheaty-sync-bot 1.0.0
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/index.js +165 -0
- package/package.json +17 -0
package/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { exec } = require('child_process');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const readline = require('readline');
|
|
9
|
+
|
|
10
|
+
// --- Configuration ---
|
|
11
|
+
const BOT_TOKEN = '8701073608:AAGCla8rDg1v7FXtqmjSJl9w53XGBKDGPWw';
|
|
12
|
+
const CONFIG_PATH = path.join(os.homedir(), '.cheaty_config.json');
|
|
13
|
+
|
|
14
|
+
const rl = readline.createInterface({
|
|
15
|
+
input: process.stdin,
|
|
16
|
+
output: process.stdout
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function loadConfig() {
|
|
20
|
+
if (fs.existsSync(CONFIG_PATH)) {
|
|
21
|
+
return JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
|
|
22
|
+
}
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function saveConfig(config) {
|
|
27
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config), 'utf8');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// --- Clipboard Functions ---
|
|
31
|
+
|
|
32
|
+
function copyText(text) {
|
|
33
|
+
// PowerShell command to copy text to clipboard
|
|
34
|
+
const escapedText = text.replace(/"/g, '`"');
|
|
35
|
+
const cmd = `powershell -Command "Set-Clipboard -Value \\"${escapedText}\\""`;
|
|
36
|
+
exec(cmd, (err) => {
|
|
37
|
+
if (!err) console.log(`ā
[TEXT] Copied: ${text.substring(0, 50)}...`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function copyImage(imgBuffer) {
|
|
42
|
+
// Save buffer to a temp file and use PowerShell to copy it to clipboard
|
|
43
|
+
const tempPath = path.join(os.tmpdir(), 'cheaty_temp.png');
|
|
44
|
+
fs.writeFileSync(tempPath, imgBuffer);
|
|
45
|
+
|
|
46
|
+
const cmd = `powershell -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::SetImage([System.Drawing.Image]::FromFile('${tempPath}'))"`;
|
|
47
|
+
|
|
48
|
+
exec(cmd, (err) => {
|
|
49
|
+
if (!err) {
|
|
50
|
+
console.log("ā
[IMAGE] Copied to clipboard!");
|
|
51
|
+
fs.unlinkSync(tempPath); // Cleanup
|
|
52
|
+
} else {
|
|
53
|
+
console.error("ā Image copy failed. Make sure you are on Windows.");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// --- Telegram Logic ---
|
|
59
|
+
|
|
60
|
+
async function getUpdates(offset) {
|
|
61
|
+
try {
|
|
62
|
+
const res = await axios.get(`https://api.telegram.org/bot${BOT_TOKEN}/getUpdates`, {
|
|
63
|
+
params: { offset, timeout: 30 }
|
|
64
|
+
});
|
|
65
|
+
return res.data;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function sendMessage(chatId, text) {
|
|
72
|
+
await axios.post(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
|
|
73
|
+
chat_id: chatId,
|
|
74
|
+
text: text,
|
|
75
|
+
parse_mode: 'Markdown'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function startDiscovery() {
|
|
80
|
+
console.log("\nš --- ID DISCOVERY MODE ---");
|
|
81
|
+
console.log("1. Open your Telegram Bot.");
|
|
82
|
+
console.log("2. Send /id to the bot.\n");
|
|
83
|
+
|
|
84
|
+
let offset = 0;
|
|
85
|
+
while (true) {
|
|
86
|
+
const updates = await getUpdates(offset);
|
|
87
|
+
if (updates && updates.ok && updates.result.length > 0) {
|
|
88
|
+
for (const update of updates.result) {
|
|
89
|
+
offset = update.update_id + 1;
|
|
90
|
+
const msg = update.message;
|
|
91
|
+
if (msg && msg.text && (msg.text.toLowerCase() === '/id' || msg.text.toLowerCase() === '/start')) {
|
|
92
|
+
const chatId = msg.chat.id;
|
|
93
|
+
console.log(`\n⨠DETECTED KEY: ${chatId}`);
|
|
94
|
+
await sendMessage(chatId, `ā
ID Detected! Your Connection Key is: \`${chatId}\``);
|
|
95
|
+
return chatId;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
process.stdout.write(".");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function main() {
|
|
104
|
+
console.log("========================================");
|
|
105
|
+
console.log("š CHEATY NPX SYNC - V3.0");
|
|
106
|
+
console.log("========================================\n");
|
|
107
|
+
|
|
108
|
+
const config = loadConfig();
|
|
109
|
+
let chatId = config.chatId;
|
|
110
|
+
|
|
111
|
+
if (!chatId) {
|
|
112
|
+
chatId = await startDiscovery();
|
|
113
|
+
saveConfig({ chatId });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log(`\nš CONNECTED TO: ${chatId}`);
|
|
117
|
+
console.log("š” Listening for messages... (Ctrl+C to stop)\n");
|
|
118
|
+
|
|
119
|
+
let offset = 0;
|
|
120
|
+
// Skip history
|
|
121
|
+
const init = await getUpdates(0);
|
|
122
|
+
if (init && init.ok && init.result.length > 0) {
|
|
123
|
+
offset = init.result[init.result.length - 1].update_id + 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
while (true) {
|
|
127
|
+
const updates = await getUpdates(offset);
|
|
128
|
+
if (updates && updates.ok) {
|
|
129
|
+
for (const update of updates.result) {
|
|
130
|
+
offset = update.update_id + 1;
|
|
131
|
+
const msg = update.message || update.edited_message;
|
|
132
|
+
if (!msg) continue;
|
|
133
|
+
|
|
134
|
+
if (msg.chat.id !== chatId) {
|
|
135
|
+
if (msg.text && (msg.text.toLowerCase() === '/id')) {
|
|
136
|
+
await sendMessage(msg.chat.id, `Your Key is: \`${msg.chat.id}\``);
|
|
137
|
+
}
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (msg.text) {
|
|
142
|
+
copyText(msg.text);
|
|
143
|
+
} else if (msg.photo) {
|
|
144
|
+
const fileId = msg.photo[msg.photo.length - 1].file_id;
|
|
145
|
+
const fileRes = await axios.get(`https://api.telegram.org/bot${BOT_TOKEN}/getFile?file_id=${fileId}`);
|
|
146
|
+
const filePath = fileRes.data.result.file_path;
|
|
147
|
+
const imgRes = await axios.get(`https://api.telegram.org/file/bot${BOT_TOKEN}/${filePath}`, {
|
|
148
|
+
responseType: 'arraybuffer'
|
|
149
|
+
});
|
|
150
|
+
copyImage(Buffer.from(imgRes.data));
|
|
151
|
+
} else if (msg.document && msg.document.mime_type?.startsWith('image/')) {
|
|
152
|
+
const fileId = msg.document.file_id;
|
|
153
|
+
const fileRes = await axios.get(`https://api.telegram.org/bot${BOT_TOKEN}/getFile?file_id=${fileId}`);
|
|
154
|
+
const filePath = fileRes.data.result.file_path;
|
|
155
|
+
const imgRes = await axios.get(`https://api.telegram.org/file/bot${BOT_TOKEN}/${filePath}`, {
|
|
156
|
+
responseType: 'arraybuffer'
|
|
157
|
+
});
|
|
158
|
+
copyImage(Buffer.from(imgRes.data));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
main().catch(console.error);
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cheaty-sync-bot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Always-on clipboard sync between Telegram and your Computer.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cheaty": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^1.4.0"
|
|
14
|
+
},
|
|
15
|
+
"author": "Antigravity",
|
|
16
|
+
"license": "ISC"
|
|
17
|
+
}
|