An unofficial Go library and CLI for IServ.
Disclaimer 1: I am not affiliated with the IServ GmbH in any way.
Disclaimer 2: This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
Disclaimer 3: Use it at YOUR OWN RISK!
iserv2go [options] command [arguments...]
Option | Description |
---|---|
-enable-email |
enables the email functionality |
-enable-files |
enables the files functionality |
-enable-web |
enables other functions (notifications, exercises, etc) |
-info |
shows program info |
-interactive |
starts interactive console where you can type commands instead of passing them as arguments |
-save-sessions |
saves login cookies on the hard drive for subsequent logins |
Command | Arguments | Description |
---|---|---|
email.list_mailboxes |
none | get a list of mailboxes |
email.read_mailbox |
mailbox path |
get last 50 messages from mailbox |
email.send_mail |
recipient address , subject , body |
send email |
files.cat |
filename |
print contents of file |
files.download |
iserv path , local path |
download file from IServ |
files.ls |
directory |
list of files in directory |
files.upload |
local path , iserv path |
upload file to IServ |
web.get_badges |
none | get badges (for modules on the nav bar left) |
web.get_current_exercises |
none | list of current exercises |
web.get_notifications |
none | get unread notifications |
web.get_past_exercises |
none | list of past exercises |
web.get_upcoming_events |
none | list of upcoming events |
# in your project directory
go get github.com/alexcoder04/iserv2go/iserv
package main
import (
"fmt"
"github.com/alexcoder04/iserv2go/iserv"
"github.com/alexcoder04/iserv2go/iserv/types"
)
func main(){
// create new client instance
client := iserv.Client{}
// login your client
err := client.Login(&types.ClientConfig{
IServHost: os.Getenv("ISERV_HOST"),
Username: os.Getenv("ISERV_USERNAME"),
Password: os.Getenv("ISERV_PASSWORD"),
EnableModules: map[string]bool{
"email": true,
"files": false,
"web": false,
},
SaveSessions: true,
})
if err != nil {
fmt.Println("failed to login")
return
}
// don't forget to logout
defer client.Logout()
// get 10 last mails in INBOX
messages, err := client.Email.ReadMailbox("INBOX", 10)
if err != nil {
return
}
// print them
for _, m := range messages {
fmt.Printf(" = '%s' from %s\n", m.Envelope.Subject, m.Envelope.Sender[0].Address())
}
}
The iserv
folder contains the Go Library, the subfolders email
, files
, web
are modules, which can be (de-)activated separately.
They contain each user.go
files, which include all the functions meant to be used by end-user.
Contributions are always welcome, there are a lot of things that wait to be implemented, see the issues. I am also looking for co-maintainers and someone to test the project extensively :)