mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 00:47:15 +08:00
refactor structure to monorepo
This commit is contained in:
@@ -1,29 +1,26 @@
|
|||||||
// export default [
|
|
||||||
// '青钱',
|
|
||||||
// '软通动力',
|
|
||||||
// '南天',
|
|
||||||
// '睿服',
|
|
||||||
// '中电金信',
|
|
||||||
// '佰钧成',
|
|
||||||
// '云链',
|
|
||||||
// '博彦',
|
|
||||||
// '汉克时代',
|
|
||||||
// '柯莱特',
|
|
||||||
// '拓保',
|
|
||||||
// '亿达信息',
|
|
||||||
// '纬创',
|
|
||||||
// '微创',
|
|
||||||
// '微澜',
|
|
||||||
// '诚迈科技',
|
|
||||||
// '法本',
|
|
||||||
// '兆尹',
|
|
||||||
// '诚迈',
|
|
||||||
// '联合永道',
|
|
||||||
// '新致软件',
|
|
||||||
// '宇信科技'
|
|
||||||
// ]
|
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
'青钱',
|
||||||
|
'软通动力',
|
||||||
|
'南天',
|
||||||
|
'睿服',
|
||||||
|
'中电金信',
|
||||||
|
'佰钧成',
|
||||||
|
'云链',
|
||||||
|
'博彦',
|
||||||
|
'汉克时代',
|
||||||
|
'柯莱特',
|
||||||
|
'拓保',
|
||||||
|
'亿达信息',
|
||||||
|
'纬创',
|
||||||
|
'微创',
|
||||||
|
'微澜',
|
||||||
|
'诚迈科技',
|
||||||
|
'法本',
|
||||||
|
'兆尹',
|
||||||
|
'诚迈',
|
||||||
|
'联合永道',
|
||||||
|
'新致软件',
|
||||||
|
'宇信科技',
|
||||||
//
|
//
|
||||||
'抖音', '字节', '字跳', '有竹居', '脸萌', '头条',
|
'抖音', '字节', '字跳', '有竹居', '脸萌', '头条',
|
||||||
//
|
//
|
||||||
@@ -117,5 +114,6 @@ export default [
|
|||||||
//
|
//
|
||||||
'好未来', '学而思', '希望学',
|
'好未来', '学而思', '希望学',
|
||||||
//
|
//
|
||||||
'新东方', '东方甄选'
|
'新东方', '东方甄选',
|
||||||
|
'作业帮'
|
||||||
]
|
]
|
||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@bossgeekgo/geek-auto-start-chat-with-boss",
|
"name": "bossgeekgo",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "geek-auto-start-chat-with-boss",
|
"description": "geek-auto-start-chat-with-boss",
|
||||||
"module": "./main/index.mjs",
|
"module": "./main/index.mjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./main/index.mjs"
|
"start": "node ./packages/run-core-of-geek-auto-start-chat-with-boss/index.mjs"
|
||||||
},
|
},
|
||||||
"author": "bossgeekgo",
|
"author": "bossgeekgo",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { requestDingtalkNotify, createTextMessage } from './dingtalk.mjs'
|
import { requestDingtalkNotify, createTextMessage } from './service.mjs'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
let sendQueueTimer = 0
|
let sendQueueTimer = 0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "@bossgeekgo/dingtalk-plugin",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "@bossgeekgo/dingtalk-plugin",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
},
|
||||||
|
"author": "bossgeekgo",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
Generated
+1108
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,13 @@
|
|||||||
import puppeteer from 'puppeteer-extra';
|
import puppeteer from 'puppeteer-extra';
|
||||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||||
|
|
||||||
import { cookies as bossCookies } from '../config/boss.mjs'
|
import { cookies as bossCookies } from '../../config/boss.mjs'
|
||||||
import targetCompanyList from '../config/target-company-list.mjs'
|
import targetCompanyList from '../../config/target-company-list.mjs'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
sleep,
|
sleep,
|
||||||
sleepWithRandomDelay
|
sleepWithRandomDelay
|
||||||
} from './utils.mjs'
|
} from '@bossgeekgo/utils/sleep.mjs'
|
||||||
|
|
||||||
import {
|
|
||||||
SyncHook,
|
|
||||||
AsyncSeriesHook
|
|
||||||
} from 'tapable'
|
|
||||||
|
|
||||||
import { initPlugins } from '../plugin/index.mjs'
|
|
||||||
|
|
||||||
puppeteer.use(StealthPlugin())
|
puppeteer.use(StealthPlugin())
|
||||||
|
|
||||||
@@ -31,7 +24,7 @@ const enableCompanyAllowList = Boolean(expectCompanySet.size)
|
|||||||
let browser, page
|
let browser, page
|
||||||
|
|
||||||
const blockBossNotNewChat = new Set()
|
const blockBossNotNewChat = new Set()
|
||||||
async function mainLoop (hooks) {
|
export async function mainLoop (hooks) {
|
||||||
try {
|
try {
|
||||||
browser = await puppeteer.launch({
|
browser = await puppeteer.launch({
|
||||||
headless: false,
|
headless: false,
|
||||||
@@ -42,7 +35,7 @@ async function mainLoop (hooks) {
|
|||||||
},
|
},
|
||||||
devtools: true
|
devtools: true
|
||||||
})
|
})
|
||||||
hooks.puppeteerLaunched.call()
|
hooks.puppeteerLaunched?.call()
|
||||||
|
|
||||||
page = await browser.newPage()
|
page = await browser.newPage()
|
||||||
sleep(2000).then(() => {
|
sleep(2000).then(() => {
|
||||||
@@ -52,7 +45,7 @@ async function mainLoop (hooks) {
|
|||||||
//set cookies
|
//set cookies
|
||||||
const copiedBossCookies = JSON.parse(JSON.stringify(bossCookies))
|
const copiedBossCookies = JSON.parse(JSON.stringify(bossCookies))
|
||||||
|
|
||||||
hooks.cookieWillSet.call(copiedBossCookies)
|
hooks.cookieWillSet?.call(copiedBossCookies)
|
||||||
for(let i = 0; i < copiedBossCookies.length; i++){
|
for(let i = 0; i < copiedBossCookies.length; i++){
|
||||||
await page.setCookie(copiedBossCookies[i]);
|
await page.setCookie(copiedBossCookies[i]);
|
||||||
}
|
}
|
||||||
@@ -61,7 +54,7 @@ async function mainLoop (hooks) {
|
|||||||
page.goto(recommendJobPageUrl, { timeout: 0 }),
|
page.goto(recommendJobPageUrl, { timeout: 0 }),
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
])
|
])
|
||||||
hooks.pageLoaded.call()
|
hooks.pageLoaded?.call()
|
||||||
|
|
||||||
const INIT_START_EXCEPT_JOB_INDEX = 1
|
const INIT_START_EXCEPT_JOB_INDEX = 1
|
||||||
let currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
let currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
||||||
@@ -194,7 +187,7 @@ async function mainLoop (hooks) {
|
|||||||
|
|
||||||
const startChatButtonInnerHTML = await page.evaluate('document.querySelector(".job-detail-box .op-btn.op-btn-chat")?.innerHTML.trim()')
|
const startChatButtonInnerHTML = await page.evaluate('document.querySelector(".job-detail-box .op-btn.op-btn-chat")?.innerHTML.trim()')
|
||||||
if (startChatButtonInnerHTML === '立即沟通') {
|
if (startChatButtonInnerHTML === '立即沟通') {
|
||||||
await hooks.newChatWillStartup.promise(jobData)
|
await hooks.newChatWillStartup?.promise(jobData)
|
||||||
const startChatButtonProxy = await page.$('.job-detail-box .op-btn.op-btn-chat')
|
const startChatButtonProxy = await page.$('.job-detail-box .op-btn.op-btn-chat')
|
||||||
await startChatButtonProxy.click()
|
await startChatButtonProxy.click()
|
||||||
|
|
||||||
@@ -219,7 +212,7 @@ async function mainLoop (hooks) {
|
|||||||
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
|
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hooks.newChatStartup.call(jobData)
|
hooks.newChatStartup?.call(jobData)
|
||||||
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
||||||
|
|
||||||
await sleepWithRandomDelay(750)
|
await sleepWithRandomDelay(750)
|
||||||
@@ -238,15 +231,15 @@ async function mainLoop (hooks) {
|
|||||||
if (
|
if (
|
||||||
currentExceptJobIndex + 1 > expectJobList.length
|
currentExceptJobIndex + 1 > expectJobList.length
|
||||||
) {
|
) {
|
||||||
hooks.noPositionFoundForCurrentJob.call()
|
hooks.noPositionFoundForCurrentJob?.call()
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.reload(),
|
page.reload(),
|
||||||
page.waitForNavigation()
|
page.waitForNavigation()
|
||||||
])
|
])
|
||||||
currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
||||||
} else {
|
} else {
|
||||||
hooks.noPositionFoundForCurrentJob.call()
|
hooks.noPositionFoundForCurrentJob?.call()
|
||||||
hooks.noPositionFoundAfterTraverseAllJob.call()
|
hooks.noPositionFoundAfterTraverseAllJob?.call()
|
||||||
|
|
||||||
currentExceptJobIndex += 1
|
currentExceptJobIndex += 1
|
||||||
}
|
}
|
||||||
@@ -256,22 +249,22 @@ async function mainLoop (hooks) {
|
|||||||
case 'STARTUP_CHAT_ERROR_DUE_TO_TODAY_CHANCE_HAS_USED_OUT': {
|
case 'STARTUP_CHAT_ERROR_DUE_TO_TODAY_CHANCE_HAS_USED_OUT': {
|
||||||
let nextTrySeconds = 60 * 60
|
let nextTrySeconds = 60 * 60
|
||||||
const msg = `Today chance has used out. Just explore positions you\'ve chatted. New chat will be tried to start after ${nextTrySeconds} seconds.`
|
const msg = `Today chance has used out. Just explore positions you\'ve chatted. New chat will be tried to start after ${nextTrySeconds} seconds.`
|
||||||
hooks.errorEncounter.call(msg)
|
hooks.errorEncounter?.call(msg)
|
||||||
console.error(msg)
|
console.error(msg)
|
||||||
await sleep(nextTrySeconds * 1000)
|
await sleep(nextTrySeconds * 1000)
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
case 'STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR': {
|
case 'STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR': {
|
||||||
hooks.errorEncounter.call([err.message, err.stack].join('\n'))
|
hooks.errorEncounter?.call([err.message, err.stack].join('\n'))
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
hooks.errorEncounter.call([err.message, err.stack].join('\n'))
|
hooks.errorEncounter?.call([err.message, err.stack].join('\n'))
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hooks.errorEncounter.call(err)
|
hooks.errorEncounter?.call(err)
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,24 +280,3 @@ async function mainLoop (hooks) {
|
|||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
|
||||||
const hooks = {
|
|
||||||
puppeteerLaunched: new SyncHook(),
|
|
||||||
pageLoaded: new SyncHook(),
|
|
||||||
cookieWillSet: new SyncHook(['cookies']),
|
|
||||||
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
|
||||||
newChatStartup: new SyncHook(['positionInfoDetail']),
|
|
||||||
noPositionFoundForCurrentJob: new SyncHook(),
|
|
||||||
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
|
||||||
errorEncounter: new SyncHook(['errorInfo'])
|
|
||||||
}
|
|
||||||
initPlugins(hooks)
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
await mainLoop(hooks)
|
|
||||||
} catch (err) {
|
|
||||||
void err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "@bossgeekgo/geek-auto-start-chat-with-boss",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "geek-auto-start-chat-with-boss",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
},
|
||||||
|
"author": "bossgeekgo",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@bossgeekgo/utils": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
||||||
+1108
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
|||||||
|
import DingtalkPlugin from '@bossgeekgo/dingtalk-plugin/index.mjs'
|
||||||
|
import { dingTalkAccessToken } from "../../config/dingtalk.mjs"
|
||||||
|
import { mainLoop } from '@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs'
|
||||||
|
import {
|
||||||
|
SyncHook,
|
||||||
|
AsyncSeriesHook
|
||||||
|
} from 'tapable'
|
||||||
|
|
||||||
|
const initPlugins = (hooks) => {
|
||||||
|
new DingtalkPlugin(dingTalkAccessToken).apply(hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
;(async () => {
|
||||||
|
const hooks = {
|
||||||
|
puppeteerLaunched: new SyncHook(),
|
||||||
|
pageLoaded: new SyncHook(),
|
||||||
|
cookieWillSet: new SyncHook(['cookies']),
|
||||||
|
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||||
|
newChatStartup: new SyncHook(['positionInfoDetail']),
|
||||||
|
noPositionFoundForCurrentJob: new SyncHook(),
|
||||||
|
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
||||||
|
errorEncounter: new SyncHook(['errorInfo'])
|
||||||
|
}
|
||||||
|
initPlugins(hooks)
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
await mainLoop(hooks)
|
||||||
|
} catch (err) {
|
||||||
|
void err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})()
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "@bossgeekgo/run-core-of-geek-auto-start-chat-with-boss",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "run-core-of-geek-auto-start-chat-with-boss",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
},
|
||||||
|
"author": "bossgeekgo",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@bossgeekgo/dingtalk-plugin": "workspace:*",
|
||||||
|
"@bossgeekgo/geek-auto-start-chat-with-boss": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@bossgeekgo/utils",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "utils",
|
||||||
|
"scripts": {
|
||||||
|
},
|
||||||
|
"author": "bossgeekgo",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
Generated
+1108
File diff suppressed because it is too large
Load Diff
@@ -1,6 +0,0 @@
|
|||||||
import DingtalkPlugin from './DingtalkPlugin/index.mjs'
|
|
||||||
import { dingTalkAccessToken } from "../config/dingtalk.mjs"
|
|
||||||
|
|
||||||
export const initPlugins = (hooks) => {
|
|
||||||
new DingtalkPlugin(dingTalkAccessToken).apply(hooks)
|
|
||||||
}
|
|
||||||
Generated
+38
-16
@@ -4,22 +4,44 @@ settings:
|
|||||||
autoInstallPeers: true
|
autoInstallPeers: true
|
||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
dependencies:
|
importers:
|
||||||
dayjs:
|
|
||||||
specifier: ^1.11.10
|
.:
|
||||||
version: 1.11.10
|
dependencies:
|
||||||
puppeteer:
|
dayjs:
|
||||||
specifier: ^21.6.1
|
specifier: ^1.11.10
|
||||||
version: 21.6.1
|
version: 1.11.10
|
||||||
puppeteer-extra:
|
puppeteer:
|
||||||
specifier: ^3.3.6
|
specifier: ^21.6.1
|
||||||
version: 3.3.6(puppeteer@21.6.1)
|
version: 21.6.1
|
||||||
puppeteer-extra-plugin-stealth:
|
puppeteer-extra:
|
||||||
specifier: ^2.11.2
|
specifier: ^3.3.6
|
||||||
version: 2.11.2(puppeteer-extra@3.3.6)
|
version: 3.3.6(puppeteer@21.6.1)
|
||||||
tapable:
|
puppeteer-extra-plugin-stealth:
|
||||||
specifier: ^2.2.1
|
specifier: ^2.11.2
|
||||||
version: 2.2.1
|
version: 2.11.2(puppeteer-extra@3.3.6)
|
||||||
|
tapable:
|
||||||
|
specifier: ^2.2.1
|
||||||
|
version: 2.2.1
|
||||||
|
|
||||||
|
packages/dingtalk-plugin: {}
|
||||||
|
|
||||||
|
packages/geek-auto-start-chat-with-boss:
|
||||||
|
dependencies:
|
||||||
|
'@bossgeekgo/utils':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../utils
|
||||||
|
|
||||||
|
packages/run-core-of-geek-auto-start-chat-with-boss:
|
||||||
|
dependencies:
|
||||||
|
'@bossgeekgo/dingtalk-plugin':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../dingtalk-plugin
|
||||||
|
'@bossgeekgo/geek-auto-start-chat-with-boss':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../geek-auto-start-chat-with-boss
|
||||||
|
|
||||||
|
packages/utils: {}
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
packages:
|
||||||
|
- 'packages/*'
|
||||||
Reference in New Issue
Block a user