@@ -95,6 +95,8 @@ func (c *Reddit) Comments(sort string, tdur string, limit int) ([]Comment, error
95
95
return nil , err
96
96
}
97
97
return comments , nil
98
+ case "redditor" :
99
+ return c .getRedditorComments (c .Chain .Name , sort , tdur , limit )
98
100
default :
99
101
return nil , fmt .Errorf ("'%s' type does not have an option for comments" , c .Chain .Type )
100
102
}
@@ -252,6 +254,30 @@ func (c *Reddit) getSubredditComments(sr string, sort string, tdur string, limit
252
254
return ret .GetChildren (), err
253
255
}
254
256
257
+ func (c * Reddit ) getRedditorComments (user string , sort string , tdur string , limit int ) ([]Comment , error ) {
258
+ target := RedditOauth + "/u/" + user + "/comments.json"
259
+ ans , err := c .MiraRequest ("GET" , target , map [string ]string {
260
+ "sort" : sort ,
261
+ "limit" : strconv .Itoa (limit ),
262
+ "t" : tdur ,
263
+ })
264
+ ret := & CommentListing {}
265
+ json .Unmarshal (ans , ret )
266
+ return ret .GetChildren (), err
267
+ }
268
+
269
+ func (c * Reddit ) getRedditorCommentsAfter (user string , sort string , last string , limit int ) ([]Comment , error ) {
270
+ target := RedditOauth + "/u/" + user + "/comments.json"
271
+ ans , err := c .MiraRequest ("GET" , target , map [string ]string {
272
+ "sort" : sort ,
273
+ "limit" : strconv .Itoa (limit ),
274
+ "before" : last ,
275
+ })
276
+ ret := & CommentListing {}
277
+ json .Unmarshal (ans , ret )
278
+ return ret .GetChildren (), err
279
+ }
280
+
255
281
func (c * Reddit ) getSubmissionComments (post_id string , sort string , tdur string , limit int ) ([]Comment , []string , error ) {
256
282
if string (post_id [1 ]) != "3" {
257
283
return nil , nil , errors .New ("the passed ID36 is not a submission" )
@@ -304,6 +330,8 @@ func (c *Reddit) CommentsAfter(sort string, last string, limit int) ([]Comment,
304
330
switch c .Chain .Type {
305
331
case "subreddit" :
306
332
return c .getSubredditCommentsAfter (c .Chain .Name , sort , last , limit )
333
+ case "redditor" :
334
+ return c .getRedditorCommentsAfter (c .Chain .Name , sort , last , limit )
307
335
default :
308
336
return nil , fmt .Errorf ("'%s' type does not have an option for comments" , c .Chain .Type )
309
337
}
0 commit comments