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