mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-24 10:20:30 -05:00
handle roles not supported canvas error
This commit is contained in:
parent
627120b31f
commit
3cf356f638
15
aplus.go
15
aplus.go
@ -16,6 +16,10 @@ import (
|
|||||||
func submit_code(course_code int, attendance_code string) bool {
|
func submit_code(course_code int, attendance_code string) bool {
|
||||||
cur_body := launch_aplus(course_code)
|
cur_body := launch_aplus(course_code)
|
||||||
if cur_body == "" {
|
if cur_body == "" {
|
||||||
|
fmt.Println("Unknown error")
|
||||||
|
return false
|
||||||
|
} else if cur_body == "Roles not supported" {
|
||||||
|
fmt.Println("Cannot access course", course_code, "(canvas error \"Roles not supported\")")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +105,12 @@ func launch_aplus(course_code int) string {
|
|||||||
|
|
||||||
resp, _ = client.PostForm(base_aplus_link, form_values)
|
resp, _ = client.PostForm(base_aplus_link, form_values)
|
||||||
body, _ = io.ReadAll(resp.Body)
|
body, _ = io.ReadAll(resp.Body)
|
||||||
return string(body)
|
|
||||||
|
if strings.Index(string(body), "Roles not supported") != -1 {
|
||||||
|
return "Roles not supported"
|
||||||
|
} else {
|
||||||
|
return string(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func get_aplus(token string, link string, client http.Client) string {
|
func get_aplus(token string, link string, client http.Client) string {
|
||||||
@ -183,6 +192,10 @@ func submit_code_sans_course(attendance_code string) {
|
|||||||
func timetable(course_code int) {
|
func timetable(course_code int) {
|
||||||
cur_body := launch_aplus(course_code)
|
cur_body := launch_aplus(course_code)
|
||||||
if cur_body == "" {
|
if cur_body == "" {
|
||||||
|
fmt.Println("Unknown error")
|
||||||
|
return
|
||||||
|
} else if cur_body == "Roles not supported" {
|
||||||
|
fmt.Println("Cannot access course", course_code, "(canvas error \"Roles not supported\")")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user