forked from dustin/go-nntp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnntp.go
50 lines (43 loc) · 1.06 KB
/
nntp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Package nntp provides base NNTP definitions.
package nntp
import (
"fmt"
"io"
"net/textproto"
)
// PostingStatus type for groups.
type PostingStatus byte
// PostingStatus values.
const (
Unknown = PostingStatus(0)
PostingPermitted = PostingStatus('y')
PostingNotPermitted = PostingStatus('n')
PostingModerated = PostingStatus('m')
)
func (ps PostingStatus) String() string {
return fmt.Sprintf("%c", ps)
}
// Group represents a usenet newsgroup.
type Group struct {
Name string
Description string
Count int64
High int64
Low int64
Posting PostingStatus
}
// An Article that may appear in one or more groups.
type Article struct {
// The article's headers
Header textproto.MIMEHeader
// The article's body
Body io.Reader
// Number of bytes in the article body (used by OVER/XOVER)
Bytes int
// Number of lines in the article body (used by OVER/XOVER)
Lines int
}
// MessageID provides convenient access to the article's Message ID.
func (a *Article) MessageID() string {
return a.Header.Get("Message-Id")
}