-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthor.go
More file actions
37 lines (34 loc) · 898 Bytes
/
author.go
File metadata and controls
37 lines (34 loc) · 898 Bytes
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
package main
import "strings"
func getDistinguished(distinguished string, isSubmitter bool) (ua userAttrs) {
ua = userAttrs{
Submitter: isSubmitter,
Moderator: strings.Contains(distinguished, "moderator"),
Admin: strings.Contains(distinguished, "admin"),
}
ln := numTrues(ua.Moderator, ua.Admin, ua.Submitter)
if ln == 0 {
ua.Letters = ""
return
}
tmp := make([]string, ln)
i := 0
if ua.Moderator {
tmp[i] = "<a href=\"#\" class=\"moderator\" title=\"moderator of this subreddit, speaking officially\">M</a>"
i++
}
if ua.Admin {
tmp[i] = "<a href=\"#\" class=\"admin\" title=\"Reddit Administrator\">A</a>"
i++
}
if ua.Submitter {
tmp[i] = "<a href=\"#\" class=\"submitter\" title=\"submitter\">S</a>"
i++
}
ua.Letters = "[" + strings.Join(tmp, ",") + "]"
return
}
func isMine(author string) bool {
return strings.
EqualFold(client.Username, author)
}