Categorygithub.com/alexcoder04/iserv2go
repositorypackage
0.2.0
Repository: https://github.com/alexcoder04/iserv2go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

iserv2go

License Go Version Lines Release Stars Contributors

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!

Use as CLI

iserv2go [options] command [arguments...]

List of options

OptionDescription
-enable-emailenables the email functionality
-enable-filesenables the files functionality
-enable-webenables other functions (notifications, exercises, etc)
-infoshows program info
-interactivestarts interactive console where you can type commands instead of passing them as arguments
-save-sessionssaves login cookies on the hard drive for subsequent logins

List of commands

CommandArgumentsDescription
email.list_mailboxesnoneget a list of mailboxes
email.read_mailboxmailbox pathget last 50 messages from mailbox
email.send_mailrecipient address, subject, bodysend email
files.catfilenameprint contents of file
files.downloadiserv path, local pathdownload file from IServ
files.lsdirectorylist of files in directory
files.uploadlocal path, iserv pathupload file to IServ
web.get_badgesnoneget badges (for modules on the nav bar left)
web.get_current_exercisesnonelist of current exercises
web.get_notificationsnoneget unread notifications
web.get_past_exercisesnonelist of past exercises
web.get_upcoming_eventsnonelist of upcoming events

Use as Library

Install

# in your project directory
go get github.com/alexcoder04/iserv2go/iserv

Example usage

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())
    }
}

Project Structure

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.

Contributing

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 :)

Credits

Contributors

Libraries