项目作者: JohannesEbke

项目描述 :
Library to develop email-based bots. Sync an IMAP folder and process emails. Record processing steps in sidecar files.
高级语言: Go
项目地址: git://github.com/JohannesEbke/emailbot.git
创建时间: 2018-04-04T19:53:30Z
项目社区:https://github.com/JohannesEbke/emailbot

开源协议:Apache License 2.0

下载


GoDoc Build Status Go Report Card

emailbot

Library to develop email-based bots.

What does it do?

This library syncs an IMAP folder to disk, and then calls processing functions separately on new and all emails.
It can record its steps in YAML sidecar files next to each email. It uses flock to lock processing steps.

Based on

github.com/JohannesEbke/go-imap-sync

Example (complete)

  1. package main
  2. import (
  3. "log"
  4. "time"
  5. "github.com/JohannesEbke/emailbot"
  6. )
  7. func main() {
  8. emailbot.Main(addDownloadedRecord, printDetails)
  9. }
  10. func addDownloadedRecord(_ string, data emailbot.SidecarData) (*emailbot.Record, error) {
  11. return &emailbot.Record{Time: time.Now(), Key: "synced"}, nil
  12. }
  13. func printDetails(emailFile string, data emailbot.SidecarData) (*emailbot.Record, error) {
  14. log.Printf("%s: %v", emailFile, data)
  15. return nil, nil
  16. }