下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:6672 【仅供学习参考】
使用时需要先配置账号信息,支持模板消息、联系人筛选、发送频率控制等功能。注意遵守微博平台规则,避免频繁操作导致账号异常。
/**
* 微博私信群发工具 v4.1
* 功能:自动登录、联系人管理、消息模板、发送监控
*/
class WeiboDMBot {
constructor(config) {
this.config = {
account: {
username: '',
password: '',
cookie: ''
},
message: {
template: "您好{name},{content}",
variables: {},
interval: 5000,
maxPerDay: 100
},
proxy: {
enable: false,
host: '',
port: ''
},
debug: true
};
Object.assign(this.config, config);
this.sentCount = 0;
this.init();
}
init() {
this.checkEnvironment();
this.setupRequestInterceptor();
this.loadCookies();
this.initUI();
}
checkEnvironment() {
if (typeof $httpClient === 'undefined') {
throw new Error('需要HTTP客户端支持');
}
}
// ... 其他初始化代码约200行 ...
}
class MessageManager {
constructor(botInstance) {
this.bot = botInstance;
this.templates = {
default: "{greeting},{name}!{content}",
promotion: "尊贵的{name}:{offer}",
notification: "通知:{content}"
};
this.variables = {
greeting: ["您好", "你好", "Hi"],
offer: ["限时优惠", "专属福利"]
};
}
generateMessage(templateName, contact) {
// 消息生成逻辑约150行...
}
parseVariables(content) {
// 变量解析逻辑约120行...
}
}
class ContactLoader {
constructor(botInstance) {
this.bot = botInstance;
this.contactSources = [
'following',
'followers',
'groups',
'custom_list'
];
}
async loadContacts(sourceType, options = {}) {
// 联系人加载逻辑约300行...
}
filterContacts(contacts, filters) {
// 联系人筛选逻辑约200行...
}
}
class ContactLoader {
constructor(botInstance) {
this.bot = botInstance;
this.contactSources = [
'following',
'followers',
'groups',
'custom_list'
];
}
async loadContacts(sourceType, options = {}) {
// 联系人加载逻辑约300行...
}
filterContacts(contacts, filters) {
// 联系人筛选逻辑约200行...
}
}
class SendController {
constructor(botInstance) {
this.bot = botInstance;
this.status = 'idle';
this.queue = [];
this.failedList = [];
this.successList = [];
}
async startSending() {
// 发送流程控制约250行...
}
async sendSingleDM(uid, content) {
// 单条私信发送实现约180行...
}
}
class SendMonitor {
constructor(botInstance) {
this.bot = botInstance;
this.stats = {
total: 0,
success: 0,
failed: 0,
startTime: null,
endTime: null
};
this.records = [];
}
recordSend(uid, status, response) {
// 发送记录统计约150行...
}
generateReport() {
// 报告生成逻辑约120行...
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。