(p *reddit1.Message)
| 904 | return nil |
| 905 | } |
| 906 | func (r *auddBot) CommentReply(p *reddit1.Message) error { |
| 907 | // Note: it looks like we don't get all the mentions through this |
| 908 | // In particular, we don't get mentions in replies to our comments |
| 909 | //j, _ := json.Marshal(p) |
| 910 | //fmt.Println("\n😻 Got a mention", string(j)) |
| 911 | fmt.Println("\n😻 Got a mention", p.Body) |
| 912 | if !p.New { |
| 913 | fmt.Println("Not a new mention") |
| 914 | return nil |
| 915 | } |
| 916 | compare := getBodyToCompare(p.Body) |
| 917 | if substringInSlice(compare, r.config.AntiTriggers) { |
| 918 | fmt.Println("Got an anti-trigger", p.Body) |
| 919 | return nil |
| 920 | } |
| 921 | |
| 922 | if strings.Contains(compare, "bad bot") || strings.Contains(compare, "damn bot") || |
| 923 | strings.Contains(compare, "stupid bot") || strings.ToLower(p.Body) == "wrong" { |
| 924 | myRepliesMu.Lock() |
| 925 | comment, exists := myReplies[p.ParentID] |
| 926 | myRepliesMu.Unlock() |
| 927 | if exists && !comment.summoned { |
| 928 | var err2 error |
| 929 | target := mira.RedditOauth + "/api/del" |
| 930 | _, err := r.r2.MiraRequest("POST", target, map[string]string{ |
| 931 | "id": comment.commentID, |
| 932 | "api_type": "json", |
| 933 | }) |
| 934 | |
| 935 | if comment.additionalCommentID != "" { |
| 936 | _, err2 = r.r2.MiraRequest("POST", target, map[string]string{ |
| 937 | "id": comment.additionalCommentID, |
| 938 | "api_type": "json", |
| 939 | }) |
| 940 | } |
| 941 | if !capture(err) && !capture(err2) { |
| 942 | myRepliesMu.Lock() |
| 943 | delete(myReplies, p.ParentID) |
| 944 | myRepliesMu.Unlock() |
| 945 | } |
| 946 | fmt.Println("got a bad bot comment", "https://reddit.com//comments/"+p.ParentID+"/"+p.ID) |
| 947 | // capture(r.r.ReadMessage(p.Name)) |
| 948 | } |
| 949 | } |
| 950 | return nil |
| 951 | } |
| 952 | func replaceSlice(s, new string, oldStrings ...string) string { |
| 953 | for _, old := range oldStrings { |
| 954 | s = strings.ReplaceAll(s, old, new) |
nothing calls this directly
no test coverage detected