下载地址:https://www.pan38.com/share.php?code=wx3Ge
声明:仅可用于学习参考使用
智能话术系统:
关键词触发回复机制
多套话术随机选择
上下文感知生成
反检测机制:
随机点击干扰
动态延迟调整
异常状态恢复
多账号支持:
账号轮换配置
独立话术设置
活跃度控制
健壮性增强:
异常处理机制
操作结果验证
自动恢复功能
使用建议:
根据实际需要修改CONFIG配置
不同平台需要调整元素定位方式
建议配合定时任务使用
=================================================================================
/*
* 跨平台智能直播间发言脚本 v2.0
* 支持:抖音/快手/小红书
* 功能:
* 1. 智能随机发言+关键词触发回复
* 2. 多账号轮换发言
* 3. 发言频率智能调整
* 4. 异常状态检测
*/
// ========== 配置文件 ==========
const CONFIG = {
platform: "douyin", // 目标平台
min_delay: 8000, // 最小发言间隔(ms)
max_delay: 20000, // 最大发言间隔(ms)
accounts: [ // 多账号配置
{ nickname: "用户1", active: true },
{ nickname: "用户2", active: false }
],
comments: { // 智能话术库
normal: [
"主播讲得真好!",
"666走一波~",
"关注了,求互关",
"这个在哪里买?"
],
keywordReply: { // 关键词触发回复
"价格": ["多少钱?", "求优惠价"],
"链接": ["上链接吧", "想要购买链接"]
}
},
advanced: { // 高级设置
prevent_detection: true, // 启用防检测
random_click: true, // 随机点击干扰
max_runtime: 3600000 // 最大运行时长(ms)
}
};
// ========== 核心功能 ==========
function main() {
// 初始化环境
if (!prepareEnvironment()) return;
// 主循环
let startTime = Date.now();
while (Date.now() - startTime < CONFIG.advanced.max_runtime) {
try {
// 智能发言流程
if (shouldComment()) {
let comment = generateComment();
if (sendComment(comment)) {
logSuccess("发言成功: " + comment);
postCommentAction();
}
}
// 防检测措施
if (CONFIG.advanced.prevent_detection) {
executeAntiDetection();
}
// 随机延迟
sleep(getSmartDelay());
} catch (e) {
logError("运行异常: " + e);
recoverFromError();
}
}
}
// ========== 功能函数 ==========
// 生成智能评论
function generateComment() {
// 先检查是否需要关键词回复
let liveContent = getLiveContent();
for (let keyword in CONFIG.comments.keywordReply) {
if (liveContent.includes(keyword)) {
let replies = CONFIG.comments.keywordReply[keyword];
return replies[Math.floor(Math.random() * replies.length)];
}
}
// 随机选择普通评论
return CONFIG.comments.normal[
Math.floor(Math.random() * CONFIG.comments.normal.length)
];
}
// 发送评论(带重试机制)
function sendComment(text, retry = 3) {
for (let i = 0; i < retry; i++) {
try {
let input = findCommentInput();
if (!input) throw "找不到输入框";
input.setText(text);
clickSendButton();
// 验证是否发送成功
if (isCommentSent(text)) {
return true;
}
} catch (e) {
logError("发送失败: " + e);
sleep(2000);
}
}
return false;
}
// ========== 工具函数 ==========
// 获取智能延迟时间
function getSmartDelay() {
let baseDelay = random(CONFIG.min_delay, CONFIG.max_delay);
// 根据直播间活跃度动态调整
let activityFactor = getLiveActivity();
return baseDelay * (activityFactor > 0.7 ? 0.8 : 1.2);
}
// 防检测随机操作
function executeAntiDetection() {
if (random(0, 1) > 0.7) {
let randomX = random(device.width * 0.2, device.width * 0.8);
let randomY = random(device.height * 0.2, device.height * 0.8);
click(randomX, randomY);
sleep(500);
}
}
// ========== 平台相关函数 ==========
function findCommentInput() {
switch (CONFIG.platform) {
case "douyin":
return className("EditText").findOne(3000);
case "kuaishou":
return id("comment_input").findOne(3000);
case "xiaohongshu":
return desc("发表评论").findOne(3000);
default:
return null;
}
}
// ========== 日志函数 ==========
function logSuccess(msg) {
console.log("✅ " + msg);
}
function logError(msg) {
console.error("❌ " + msg);
}
// ========== 初始化 ==========
main();
============================================================================
ui:
===========================================================================
"ui";
const APP_NAME = "直播间智能助手";
// 主界面布局
ui.layout(
<vertical padding="16" bg="#f5f5f5">
<text text={APP_NAME} textSize="20sp" textColor="#333" gravity="center"/>
<horizontal marginTop="16">
<text text="目标平台:" textSize="16sp" layout_weight="1"/>
<spinner id="platform" entries="抖音,快手,小红书" layout_weight="2"/>
</horizontal>
<horizontal marginTop="8">
<text text="发言间隔:" textSize="16sp" layout_weight="1"/>
<seekbar id="delay" max="30" progress="10" layout_weight="2"/>
<text id="delayValue" text="10秒" textSize="14sp" marginLeft="8"/>
</horizontal>
<text text="预设话术:" textSize="16sp" marginTop="16"/>
<input id="newComment" hint="输入新话术" marginTop="4"/>
<button id="addComment" text="添加话术" marginTop="8"/>
<list id="commentList" layout_weight="1" marginTop="8">
<horizontal padding="8" bg="?selectableItemBackground">
<text text="{{this}}" textSize="14sp" layout_weight="1"/>
<button id="remove" text="删除" tag="{{this}}"/>
</horizontal>
</list>
<horizontal marginTop="16">
<button id="start" text="开始运行" layout_weight="1" style="Widget.AppCompat.Button.Colored"/>
<button id="stop" text="停止" layout_weight="1" style="Widget.AppCompat.Button.Borderless"/>
</horizontal>
</vertical>
);
// 初始化数据
let comments = ["主播好棒!", "666走一波~"];
ui.commentList.setDataSource(comments);
// 事件监听
ui.delay.on("progress_change", (seekbar, progress) => {
ui.delayValue.setText(progress + "秒");
});
ui.addComment.click(() => {
let text = ui.newComment.text();
if (text) {
comments.push(text);
ui.commentList.setDataSource(comments);
ui.newComment.setText("");
}
});
ui.commentList.on("item_click", (item, pos) => {
ui.newComment.setText(item);
});
ui.commentList.on("item_bind", (view, pos) => {
view.remove.on("click", () => {
comments.splice(pos, 1);
ui.commentList.setDataSource(comments);
});
});
ui.start.click(() => {
threads.start(function() {
startScript();
});
});
ui.stop.click(() => {
stopScript();
});
// 脚本控制函数
function startScript() {
toast("脚本开始运行");
// 这里调用核心功能代码
}
function stopScript() {
toast("脚本已停止");
}
====================================================================
