Files
imap2asana/imap2asana.go

59 lines
733 B
Go
Raw Normal View History

2022-10-30 20:31:51 +00:00
package main
import (
"fmt"
2022-10-30 22:29:36 +00:00
"log"
"math/rand"
2022-10-30 20:31:51 +00:00
"os"
2022-10-30 22:29:36 +00:00
"time"
2022-10-30 20:31:51 +00:00
)
func main() {
2022-10-30 22:29:36 +00:00
rand.Seed(time.Now().UnixNano())
2022-10-30 20:31:51 +00:00
ic, err := NewImapClient(
os.Getenv("IMAP_HOST"),
os.Getenv("IMAP_USERNAME"),
os.Getenv("IMAP_PASSWORD"),
2022-10-30 22:23:45 +00:00
"Asana",
"Archive",
2022-10-30 20:31:51 +00:00
)
if err != nil {
panic(err)
}
defer ic.Close()
2022-10-30 22:29:36 +00:00
err = Poll(ic)
2022-10-30 20:31:51 +00:00
if err != nil {
2022-10-30 22:29:36 +00:00
log.Printf("%s", err)
2022-10-30 20:31:51 +00:00
}
2022-10-30 22:29:36 +00:00
for {
time.Sleep(time.Duration(rand.Intn(60)) * time.Second)
err := Poll(ic)
if err != nil {
log.Printf("%s", err)
}
2022-10-30 20:31:51 +00:00
}
}
2022-10-30 22:23:45 +00:00
type Task struct {
Name string
HtmlNotes string
2022-10-30 20:31:51 +00:00
}
2022-10-30 22:29:36 +00:00
func Poll(ic *ImapClient) error {
tasks, err := ic.Poll()
if err != nil {
return err
}
for _, task := range tasks {
fmt.Printf("%#v\n", task)
}
return nil
}