fixed decleration problem
This commit is contained in:
parent
58415419bc
commit
71d83a6ada
2 changed files with 7 additions and 32 deletions
|
|
@ -71,6 +71,12 @@ type params struct {
|
|||
Id int `json:"id"`
|
||||
Type int `json:"type"`
|
||||
}
|
||||
type Loginresult struct {
|
||||
SessionID string `json:"sessionId"`
|
||||
PersonType int `json:"personType"`
|
||||
PersonID int `json:"personId"`
|
||||
KlasseID int `json:"klasseId"`
|
||||
}
|
||||
|
||||
func ReadLoginResultFromFile(path string) (Loginresult, error) {
|
||||
var result Loginresult
|
||||
|
|
|
|||
33
Bot/Untis.go
33
Bot/Untis.go
|
|
@ -3,7 +3,6 @@ package Untis
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -24,17 +23,6 @@ type Login struct {
|
|||
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
}
|
||||
type LoginResponse struct {
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
ID string `json:"id"`
|
||||
Result Loginresult `json:"result"`
|
||||
}
|
||||
type Loginresult struct {
|
||||
SessionID string `json:"sessionId"`
|
||||
PersonType int `json:"personType"`
|
||||
PersonID int `json:"personId"`
|
||||
KlasseID int `json:"klasseId"`
|
||||
}
|
||||
|
||||
var Url = "https://thalia.webuntis.com/WebUntis/jsonrpc.do?school=Mons_Tabor"
|
||||
var Password = os.Getenv("UNTIS_PASSWORD")
|
||||
|
|
@ -55,7 +43,6 @@ func Main() {
|
|||
|
||||
//getTeachers sends empty response -> commented out
|
||||
//Teachers(cookies)
|
||||
Timetable(cookies)
|
||||
}
|
||||
|
||||
func Auth() ([]*http.Cookie, error) {
|
||||
|
|
@ -81,25 +68,7 @@ func Auth() ([]*http.Cookie, error) {
|
|||
//log.Println("Set-Cookie headers:", LoginOut.Header["Set-Cookie"])
|
||||
//loginRespBody, _ := io.ReadAll(LoginOut.Body)
|
||||
//log.Println("Login response body:", string(loginRespBody))
|
||||
//log.Println("Login successful")
|
||||
response, err := io.ReadAll(LoginOut.Body)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading response body: %v", err)
|
||||
}
|
||||
var Response LoginResponse
|
||||
err = json.Unmarshal(response, &Response)
|
||||
if err != nil {
|
||||
log.Fatalf("Error unmarshaling response: %v", err)
|
||||
}
|
||||
data, err := json.MarshalIndent(Response.Result, "", " ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = os.WriteFile("login.json", data, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("Login successful")
|
||||
return cookies, nil
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue