summaryrefslogtreecommitdiff
path: root/aplus.go
diff options
context:
space:
mode:
authorvin <git@vineetk.net>2024-01-16 14:56:55 -0500
committervin <git@vineetk.net>2024-01-16 14:56:55 -0500
commit3cf356f63895686e34aa0560c71dcb1ff8c29397 (patch)
tree22bd50e4c23bb9a5c72a4395861d0f996b6b89cb /aplus.go
parent627120b31f22f2f286fc2552f4586f29e7e1762c (diff)
handle roles not supported canvas error
Diffstat (limited to 'aplus.go')
-rw-r--r--aplus.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/aplus.go b/aplus.go
index e546b6c..a84df8c 100644
--- a/aplus.go
+++ b/aplus.go
@@ -16,6 +16,10 @@ import (
16func submit_code(course_code int, attendance_code string) bool { 16func submit_code(course_code int, attendance_code string) bool {
17 cur_body := launch_aplus(course_code) 17 cur_body := launch_aplus(course_code)
18 if cur_body == "" { 18 if cur_body == "" {
19 fmt.Println("Unknown error")
20 return false
21 } else if cur_body == "Roles not supported" {
22 fmt.Println("Cannot access course", course_code, "(canvas error \"Roles not supported\")")
19 return false 23 return false
20 } 24 }
21 25
@@ -101,7 +105,12 @@ func launch_aplus(course_code int) string {
101 105
102 resp, _ = client.PostForm(base_aplus_link, form_values) 106 resp, _ = client.PostForm(base_aplus_link, form_values)
103 body, _ = io.ReadAll(resp.Body) 107 body, _ = io.ReadAll(resp.Body)
104 return string(body) 108
109 if strings.Index(string(body), "Roles not supported") != -1 {
110 return "Roles not supported"
111 } else {
112 return string(body)
113 }
105} 114}
106 115
107func get_aplus(token string, link string, client http.Client) string { 116func get_aplus(token string, link string, client http.Client) string {
@@ -183,6 +192,10 @@ func submit_code_sans_course(attendance_code string) {
183func timetable(course_code int) { 192func timetable(course_code int) {
184 cur_body := launch_aplus(course_code) 193 cur_body := launch_aplus(course_code)
185 if cur_body == "" { 194 if cur_body == "" {
195 fmt.Println("Unknown error")
196 return
197 } else if cur_body == "Roles not supported" {
198 fmt.Println("Cannot access course", course_code, "(canvas error \"Roles not supported\")")
186 return 199 return
187 } 200 }
188 201