diff options
| author | lost+skunk <[email protected]> | 2024-06-30 14:39:11 +0300 |
|---|---|---|
| committer | lost+skunk <[email protected]> | 2024-06-30 14:39:11 +0300 |
| commit | 949bef2c5d5ee53a5d6158e16921c698f8a6e266 (patch) | |
| tree | 5d6fb17999bfd41ed98e6caa1453a3874afe9867 /comments.go | |
| parent | efa4b86a67d67ce9ff1ff19391dbf73f13daece6 (diff) | |
| download | devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.tar.gz devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.tar.bz2 devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.zip | |
по мелочи
Diffstat (limited to 'comments.go')
| -rw-r--r-- | comments.go | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/comments.go b/comments.go index 47a0136..928de44 100644 --- a/comments.go +++ b/comments.go @@ -2,48 +2,45 @@ package devianter import ( "encoding/json" + "net/url" "strconv" - "strings" ) +type Thread struct { + Replies, Likes int + ID int `json:"commentId"` + Parent int `json:"parentId"` + + Posted time + Author bool `json:"isAuthorHighlited"` + + Desctiption string + Comment string + + TextContent Text + + User struct { + Username string + Banned bool `json:"isBanned"` + } +} + type Comments struct { Cursor string PrevOffset int HasMore, HasLess bool Total int - Thread []struct { - Replies, Likes int - ID int `json:"commentId"` - Parent int `json:"parentId"` - - Posted time - Author bool `json:"isAuthorHighlited"` - - Desctiption string - Comment string - - TextContent Text - - User struct { - Username string - Banned bool `json:"isBanned"` - } - } + Thread []Thread } -// функция для обработки комментариев поста, пользователя, группы и многого другого -func CommentsFunc( - postid string, - cursor string, - page int, - typ int, // 1 - комментарии поста; 4 - комментарии на стене группы или пользователя -) (cmmts Comments) { +// 1 - комментарии поста; 4 - комментарии на стене группы или пользователя +func CommentsFunc(postid string, cursor string, page int, typ int) (cmmts Comments) { for x := 0; x <= page; x++ { ujson( "dashared/comments/thread?typeid="+strconv.Itoa(typ)+ "&itemid="+postid+"&maxdepth=1000&order=newest"+ - "&limit=50&cursor="+strings.ReplaceAll(cursor, "+", `%2B`), + "&limit=50&cursor="+url.QueryEscape(cursor), &cmmts, ) |
