自动点赞 模拟登录前置到开启多进程前 防止重复登录
This commit is contained in:
@@ -197,10 +197,18 @@ class WorkbenchJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 将好友列表分成20组
|
// 将好友列表分成20组
|
||||||
$friendGroups = array_chunk($friendList, 10);
|
$friendGroups = array_chunk($friendList, 20);
|
||||||
|
|
||||||
$processes = [];
|
$processes = [];
|
||||||
|
|
||||||
|
// 初始化WebSocketController
|
||||||
|
$username = Env::get('api.username', '');
|
||||||
|
$password = Env::get('api.password', '');
|
||||||
|
$toAccountId = '';
|
||||||
|
if (!empty($username) || !empty($password)) {
|
||||||
|
$toAccountId = Db::name('users')->where('account',$username)->value('s2_accountId');
|
||||||
|
}
|
||||||
|
$webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]);
|
||||||
|
|
||||||
foreach ($friendGroups as $groupIndex => $friendGroup) {
|
foreach ($friendGroups as $groupIndex => $friendGroup) {
|
||||||
// 创建子进程
|
// 创建子进程
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
@@ -216,7 +224,6 @@ class WorkbenchJob
|
|||||||
// 子进程
|
// 子进程
|
||||||
try {
|
try {
|
||||||
foreach ($friendGroup as $friend) {
|
foreach ($friendGroup as $friend) {
|
||||||
|
|
||||||
// 验证是否达到点赞次数上限
|
// 验证是否达到点赞次数上限
|
||||||
$likeCount = $this->getTodayLikeCount($workbench, $config, $friend['deviceId']);
|
$likeCount = $this->getTodayLikeCount($workbench, $config, $friend['deviceId']);
|
||||||
if ($likeCount >= $config['maxLikes']) {
|
if ($likeCount >= $config['maxLikes']) {
|
||||||
@@ -231,7 +238,7 @@ class WorkbenchJob
|
|||||||
->count();
|
->count();
|
||||||
|
|
||||||
if ($friendMaxLikes < $config['friendMaxLikes']) {
|
if ($friendMaxLikes < $config['friendMaxLikes']) {
|
||||||
$this->processFriendMoments($workbench, $config, $friend);
|
$this->processFriendMoments($workbench, $config, $friend, $webSocket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -307,8 +314,9 @@ class WorkbenchJob
|
|||||||
* @param Workbench $workbench
|
* @param Workbench $workbench
|
||||||
* @param WorkbenchAutoLike $config
|
* @param WorkbenchAutoLike $config
|
||||||
* @param array $friend
|
* @param array $friend
|
||||||
|
* @param WebSocketController $webSocket
|
||||||
*/
|
*/
|
||||||
protected function processFriendMoments($workbench, $config, $friend)
|
protected function processFriendMoments($workbench, $config, $friend, $webSocket)
|
||||||
{
|
{
|
||||||
$toAccountId = '';
|
$toAccountId = '';
|
||||||
$username = Env::get('api.username', '');
|
$username = Env::get('api.username', '');
|
||||||
@@ -323,7 +331,6 @@ class WorkbenchJob
|
|||||||
$automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $toAccountId], true);
|
$automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $toAccountId], true);
|
||||||
|
|
||||||
// 执行采集朋友圈命令
|
// 执行采集朋友圈命令
|
||||||
$webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]);
|
|
||||||
$webSocket->getMoments(['wechatFriendId' => $friend['friendId'], 'wechatAccountId' => $friend['wechatAccountId']]);
|
$webSocket->getMoments(['wechatFriendId' => $friend['friendId'], 'wechatAccountId' => $friend['wechatAccountId']]);
|
||||||
|
|
||||||
// 查询未点赞的朋友圈
|
// 查询未点赞的朋友圈
|
||||||
|
|||||||
Reference in New Issue
Block a user