Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신원형
/
study-or-enjoy
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
신원형
2022-06-06 12:14:13 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
973af2d41c990e553caa6b48fce7dd1de4625af0
973af2d4
1 parent
50b95128
bug fix e-campus login
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
32 deletions
khcanvas.js
main.js
schedule_selector.js
test/khcanvas_test.js
khcanvas.js
View file @
973af2d
...
...
@@ -40,17 +40,17 @@ ex)
*/
async
function
get_schedule
(
id
,
pw
,
target_date
)
{
return
await
using_selenium
(
async
(
driver
)
=>
{
console
.
log
(
"entered get_schedule_then"
)
const
result
=
await
using_selenium
(
async
(
driver
)
=>
{
console
.
log
(
"entered using_selenium_then"
)
return
await
login
(
driver
,
id
,
pw
)
.
then
(
async
()
=>
{
console
.
log
(
"entered login_then"
)
return
await
load
(
driver
,
target_date
)
.
then
((
data
)
=>
{
//logout(driver)
console
.
log
(
data
)
return
data
})
})
})
return
await
result
}
async
function
using_selenium
(
next
)
{
...
...
@@ -62,9 +62,13 @@ async function using_selenium(next) {
.
setFirefoxOptions
(
option
)
.
build
()
next
(
driver
).
finally
(()
=>
{
driver
.
quit
()
})
const
result
=
next
(
driver
)
return
await
result
//await next(driver).finally(() => {
// driver.quit()
//})
}
async
function
login
(
driver
,
id
,
pw
)
{
...
...
main.js
View file @
973af2d
...
...
@@ -72,10 +72,10 @@ function sendLocation(replyToken, latitude, longitude, locationAdd, locationName
});
}
function
filter_date
(
date
,
id
,
pw
)
{
//const schedule =
canvas.get_schedule(id, pw, date)
//
const first_todo = selector.is_possible_schedule(date, schedule)
const
first_todo
=
false
async
function
filter_date
(
date
,
id
,
pw
)
{
const
schedule
=
await
canvas
.
get_schedule
(
id
,
pw
,
date
)
const
first_todo
=
selector
.
is_possible_schedule
(
date
,
schedule
)
//
const first_todo = false
if
(
first_todo
)
{
return
`제출되지 않은 과제가 있습니다.
${
first_todo
}
`
}
...
...
@@ -84,6 +84,7 @@ function filter_date(date, id, pw) {
}
function
is_good_weather
(
weather_data
)
{
console
.
log
(
"current weather is :"
+
weather_data
.
weather
[
0
].
id
)
if
(
weather_data
.
id
<
800
)
{
return
false
}
...
...
@@ -177,13 +178,13 @@ app.post('/hook', async function (req, res) {
if
(
first
==
false
&&
eventObj
.
message
.
text
==
"처음"
)
{
const
today
=
new
Date
()
const
filter_result
=
filter_date
(
today
,
id
,
pw
)
const
filter_result
=
await
filter_date
(
today
,
id
,
pw
)
if
(
filter_result
)
{
sendText
(
eventObj
.
replyToken
,
filter_result
)
}
const
good_weather
=
(
weather
.
get_weather_current
()
).
then
(
it
=>
{
const
good_weather
=
await
weather
.
get_weather_current
(
).
then
(
it
=>
{
return
is_good_weather
(
it
)
})
if
(
!
good_weather
)
{
...
...
schedule_selector.js
View file @
973af2d
...
...
@@ -22,7 +22,7 @@ async function is_possible_schedule(date, assignments) {
return
current_timestamp
>
(
target_timestamp
-
ADayForMS
)
})
if
(
is_disqualified
)
{
if
(
is_disqualified
.
length
>
0
)
{
const
disq
=
is_disqualified
.
at
(
0
)
return
`
${
disq
.
course_name
}
:
${
disq
.
assignment_name
}
[
${
disq
.
points
}
점]`
}
else
{
...
...
test/khcanvas_test.js
View file @
973af2d
...
...
@@ -9,18 +9,6 @@ const util = require('util')
const
assert
=
require
(
'assert'
)
mocha
.
describe
(
'khcanvas'
,
()
=>
{
mocha
.
it
(
'opening selenium'
,
async
()
=>
{
await
canvas
.
using_selenium
(
async
(
driver
)
=>
{
await
driver
.
get
(
"http://khuhub.khu.ac.kr"
);
await
driver
.
getTitle
().
then
(
(
title
)
=>
{
console
.
log
(
title
);
});
});
})
});
mocha
.
describe
(
'khcanvas'
,
()
=>
{
mocha
.
it
(
'get schedule'
,
async
()
=>
{
const
rl
=
rd
.
createInterface
({
input
:
process
.
stdin
,
...
...
@@ -29,13 +17,15 @@ mocha.describe('khcanvas', () => {
const
question
=
util
.
promisify
(
rl
.
question
).
bind
(
rl
);
const
a
=
await
question
(
'a'
);
const
b
=
await
question
(
'b'
);
const
fs
=
require
(
'fs'
);
const
tokens
=
JSON
.
parse
(
fs
.
readFileSync
(
"setting.json"
))
const
a
=
tokens
.
id
const
b
=
tokens
.
pw
return
await
canvas
.
get_schedule
(
a
,
b
,
new
Date
())
.
then
(
it
=>
console
.
log
(
it
))
.
then
(
it
=>
console
.
log
(
"log at: "
+
it
))
.
catch
(
it
=>
{
console
.
log
(
it
)
console
.
log
(
"log at (2): "
+
it
)
assert
.
rejects
(
it
)
})
})
...
...
Please
register
or
login
to post a comment