fix rec out format, set local time, fix n
This commit is contained in:
23
recv.go
23
recv.go
@@ -1,9 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"local/args"
|
||||
"local/sandbox/contact/contact"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -23,6 +27,21 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
for msg := range msgs {
|
||||
log.Println(msg)
|
||||
b, _ := ioutil.ReadAll(io.LimitReader(msg.Body, 1024))
|
||||
s := strings.ReplaceAll(string(b), "\r\n", " ")
|
||||
s = strings.ReplaceAll(string(s), "\n", " ")
|
||||
s = strings.ReplaceAll(string(s), "\r", " ")
|
||||
if !strings.Contains(s, " ") {
|
||||
s = "..."
|
||||
}
|
||||
d, _ := msg.Header.Date()
|
||||
d = d.In(time.Local)
|
||||
fmt.Printf(
|
||||
"@%+v @%+v: %+v: %s\n",
|
||||
d.Format("06-01-02T15:04Z07"),
|
||||
msg.Header.Get("From"),
|
||||
msg.Header.Get("Subject"),
|
||||
s,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user