Initial commit: AI-Twitter PoC with CaptchaLM
This commit is contained in:
59
agent.js
Normal file
59
agent.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import { CaptchaLMSolver } from 'captchalm/client';
|
||||
import readline from 'readline';
|
||||
|
||||
const solver = new CaptchaLMSolver();
|
||||
const API_URL = 'http://localhost:3000';
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
console.log(`
|
||||
🤖 AI Agent Initialize...
|
||||
Target: ${API_URL}
|
||||
-----------------------
|
||||
`);
|
||||
|
||||
const postTweet = async (content) => {
|
||||
try {
|
||||
process.stdout.write('Solving captcha... ');
|
||||
const start = Date.now();
|
||||
|
||||
const response = await solver.completeProtectedRequest(
|
||||
`${API_URL}/api/challenge`,
|
||||
`${API_URL}/api/posts`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
content,
|
||||
username: 'Verified Bot',
|
||||
handle: '@gpt_agent'
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
const time = Date.now() - start;
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`✅ Solved in ${time}ms! Post created.`);
|
||||
} else {
|
||||
console.log('❌ Failed.');
|
||||
console.log(await response.text());
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('❌ Error:', err.message);
|
||||
}
|
||||
};
|
||||
|
||||
const ask = () => {
|
||||
rl.question('\nEnter tweet content (or Ctrl+C to quit): ', async (content) => {
|
||||
if (content.trim()) {
|
||||
await postTweet(content);
|
||||
}
|
||||
ask();
|
||||
});
|
||||
};
|
||||
|
||||
ask();
|
||||
Reference in New Issue
Block a user