mirror of
https://git.mapside.kr/public/lotto_automation.git
synced 2026-09-21 00:05:02 +09:00
Compare commits
9
Commits
0950a01f96
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c5b413d84 | ||
|
|
90cbc95ee2 | ||
|
|
bccdee3ae4 | ||
|
|
e5d59a836d | ||
|
|
da09a696ef | ||
|
|
f900ef5039 | ||
|
|
d226357f5f | ||
|
|
092df29869 | ||
|
|
4301e3003f |
@@ -4,3 +4,4 @@ node_modules
|
|||||||
test
|
test
|
||||||
yarn.lock
|
yarn.lock
|
||||||
config.json
|
config.json
|
||||||
|
package-lock.json
|
||||||
@@ -6,22 +6,24 @@ const NTFY = require('./lib/ntfy')
|
|||||||
const Constants = require('./lib/constants')
|
const Constants = require('./lib/constants')
|
||||||
|
|
||||||
new class LottoAutomation {
|
new class LottoAutomation {
|
||||||
#config = {}
|
#configFilename = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'config.json'
|
||||||
|
#configPath = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? __dirname}/${this.#configFilename}`
|
||||||
|
#config = {}
|
||||||
|
|
||||||
#_start() {
|
#_start() {
|
||||||
this.#_loadConfig()
|
this.#_loadConfig()
|
||||||
setImmediate(this.#_buyLotto.bind(this))
|
setImmediate(this.#_buyLotto.bind(this))
|
||||||
}
|
}
|
||||||
#_loadConfig() {
|
#_loadConfig() {
|
||||||
if(!Fs.existsSync(Constants.CONFIG_PATH))
|
if(!Fs.existsSync(this.#configPath))
|
||||||
throw new Error('Config.json 파일이 존재하지 않습니다.')
|
throw new Error('config.json 파일이 존재하지 않습니다.')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const configString = Fs.readFileSync(Constants.CONFIG_PATH)
|
const configString = Fs.readFileSync(this.#configPath)
|
||||||
this.#config = JSON.parse(configString)
|
this.#config = JSON.parse(configString)
|
||||||
NTFY.Init(this.#config.ntfyUrl, this.#config.ntfyToken)
|
NTFY.Init(this.#config.ntfyUrl, this.#config.ntfyToken)
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
throw new Error('Config.json 파일이 올바르지 않습니다.')
|
throw new Error('config.json 파일이 올바르지 않습니다.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async #_buyLotto() {
|
async #_buyLotto() {
|
||||||
@@ -36,7 +38,7 @@ new class LottoAutomation {
|
|||||||
const successMessageArr = [
|
const successMessageArr = [
|
||||||
`구매 성공`,
|
`구매 성공`,
|
||||||
`ROUND: ${buyResult.round}`,
|
`ROUND: ${buyResult.round}`,
|
||||||
`COST : ${buyResult.cost}`,
|
`COST: ${buyResult.cost}`,
|
||||||
]
|
]
|
||||||
successMessageArr.push(
|
successMessageArr.push(
|
||||||
...buyResult.numbers.map(numberStr => {
|
...buyResult.numbers.map(numberStr => {
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
"ntfyToken": "TOKEN",
|
"ntfyToken": "TOKEN",
|
||||||
"buyLottoPolicy": [
|
"buyLottoPolicy": [
|
||||||
"auto",
|
"auto",
|
||||||
"1,2,3,4,5,6"
|
[1,2,3,4,5,6]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+1
-3
@@ -6,6 +6,7 @@ class Constants {
|
|||||||
static SYSTEM_CHECK_URL = `${Constants.BASE_URL}/index_check.html`
|
static SYSTEM_CHECK_URL = `${Constants.BASE_URL}/index_check.html`
|
||||||
static MAIN_PAGE_URL = `${Constants.BASE_URL}/common.do?method=main`
|
static MAIN_PAGE_URL = `${Constants.BASE_URL}/common.do?method=main`
|
||||||
static LOGIN_REQUEST_URL = `${Constants.BASE_URL}/userSsl.do?method=login`
|
static LOGIN_REQUEST_URL = `${Constants.BASE_URL}/userSsl.do?method=login`
|
||||||
|
static PW_CHANGE_NEXT_URL = `${Constants.BASE_URL}/userSsl.do?method=pspnPwChng`
|
||||||
static BUY_PAGE_URL = `${Constants.API_URL}/olotto/game/game645.do`
|
static BUY_PAGE_URL = `${Constants.API_URL}/olotto/game/game645.do`
|
||||||
static BUY_LOTTO_645_URL = `${Constants.API_URL}/olotto/game/execBuy.do`
|
static BUY_LOTTO_645_URL = `${Constants.API_URL}/olotto/game/execBuy.do`
|
||||||
static BUY_READY_SOCKET_URL = `${Constants.API_URL}/olotto/game/egovUserReadySocket.json`
|
static BUY_READY_SOCKET_URL = `${Constants.API_URL}/olotto/game/egovUserReadySocket.json`
|
||||||
@@ -36,9 +37,6 @@ class Constants {
|
|||||||
'2': '반자동',
|
'2': '반자동',
|
||||||
'3': '자동'
|
'3': '자동'
|
||||||
}
|
}
|
||||||
|
|
||||||
static CONFIG_FILENAME = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'Config.json'
|
|
||||||
static CONFIG_PATH = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? '.'}/${Constants.CONFIG_FILENAME}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Constants
|
module.exports = Constants
|
||||||
+29
-2
@@ -62,7 +62,34 @@ class Lotto {
|
|||||||
if(loginResult instanceof Error)
|
if(loginResult instanceof Error)
|
||||||
return loginResult
|
return loginResult
|
||||||
|
|
||||||
const $ = Cheerio.load(loginResult.data)
|
let $ = Cheerio.load(loginResult.data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 비밀번호 변경 감지
|
||||||
|
*
|
||||||
|
* 비밀번호가 변경이 될 경우 'https://www.dhlottery.co.kr/userSsl.do?method=pwdPlyChngNoti'로 redirect 됨
|
||||||
|
* 비밀번호를 유지할 지 변경할 지 고르는 페이지인데, 여기에 있는 chngTgtId 및 pwdChgToken를 추출해서
|
||||||
|
*
|
||||||
|
* POST 'https://www.dhlottery.co.kr/userSsl.do?method=pspnPwChng'
|
||||||
|
* payload로 chngTgtId, pwdChgToken을 보내면 다음에 하기 처리됨.
|
||||||
|
*
|
||||||
|
* 성공하면 'https://www.dhlottery.co.kr/user.do?method=login&returnUrl=https%3A%2F%2Fwww.dhlottery.co.kr%2Fcommon.do%3Fmethod%3Dmain'
|
||||||
|
* redirect 진행되며, 마지막으로 MAIN_PAGE_URL로 redirect됨
|
||||||
|
*/
|
||||||
|
const targetInput = $('#chngTgtId')
|
||||||
|
if(targetInput.length !== 0) {
|
||||||
|
const chngTgtId = targetInput.val()
|
||||||
|
const pwdChgToken = $('#pwdChgToken').val()
|
||||||
|
|
||||||
|
const pwChgNextData = { chngTgtId, pwdChgToken }
|
||||||
|
const pgChgNextResult = await this.#_request('POST', Constants.PW_CHANGE_NEXT_URL, pwChgNextData)
|
||||||
|
if(pgChgNextResult instanceof Error)
|
||||||
|
return pgChgNextResult
|
||||||
|
|
||||||
|
$ = Cheerio.load(pgChgNextResult.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const btnCommonElements = $('a.btn_common')
|
const btnCommonElements = $('a.btn_common')
|
||||||
if(btnCommonElements.length > 0)
|
if(btnCommonElements.length > 0)
|
||||||
return new Error('로그인에 실패했습니다. 아이디 또는 비밀번호를 확인해주세요.')
|
return new Error('로그인에 실패했습니다. 아이디 또는 비밀번호를 확인해주세요.')
|
||||||
@@ -86,7 +113,7 @@ class Lotto {
|
|||||||
const requestParams = lotteryInputs.map((lotto, idx) => {
|
const requestParams = lotteryInputs.map((lotto, idx) => {
|
||||||
return {
|
return {
|
||||||
genType: lotto === 'auto' ? '0' : '1',
|
genType: lotto === 'auto' ? '0' : '1',
|
||||||
arrGameChoiceNum: lotto === 'auto' ? null : lotto.map(num => String(num).padStart(2, 0)).join(','),
|
arrGameChoiceNum: lotto === 'auto' ? null : lotto.sort().map(num => String(num).padStart(2, 0)).join(','),
|
||||||
alpabet: String.fromCharCode(65 + idx)
|
alpabet: String.fromCharCode(65 + idx)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user