1
0
Fork 0

- added a script to get a list of people user is following.

This commit is contained in:
cage 2021-11-14 13:44:58 +01:00
parent 2597c131cd
commit 4b649d91ae
4 changed files with 67 additions and 2 deletions

View File

@ -0,0 +1,40 @@
;; geat a list of people you are following
;; Copyright © 2021 cage
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; usage:
;; after configuring tinmop (https://www.autistici.org/interzona/tinmop.html)
;; tinmop -e get-following.lisp > follows.csv
(in-package :scripts)
(defun connect ()
(client:init)
(client:authorize))
(defun main ()
(connect)
(db-utils:with-ready-database (:connect t)
(let* ((username (db:acct->id (swconf:config-username)))
(local-server-name (swconf:config-server-name))
(follows-accounts (api-pleroma:get-following username)))
(loop for account in follows-accounts do
(let ((acct (tooter:account-name account)))
(if (scan "@" acct)
(format t "~s~%" acct)
(format t "\"~a@~a\"~%" acct local-server-name)))))))
(main)

View File

@ -511,7 +511,7 @@ database."
(tooter:unfollow *client* user-id))
(defun-api-call follow-requests ()
"Gets the request tio follow the user of this client"
"Gets the request to follow the user of this client"
(let ((requests (tooter:follow-requests *client*)))
(values requests
(mapcar #'tooter:account-name requests))))

View File

@ -117,5 +117,29 @@ media `media'. Returns a `chat-message' instance"
(api-pleroma:post-chat-message api-client:*client* chat-id nil message)
(api-pleroma:post-chat-message api-client:*client* chat-id message nil)))
(defmethod get-following-accounts ((client tooter:client) (id string)
&key
(max-id nil)
(min-id nil)
(since-id nil)
(limit 10)
(offset 0))
(decode-account (tooter:query client
(format nil "/api/v1/accounts/~a/following" id)
:max-id max-id
:min-id min-id
:since-id since-id
:limit limit
:offset offset)))
(api-client:defun-api-call create-new-chat (user-id)
(create-chat api-client:*client* user-id))
(api-client:defun-api-call get-following (user-id &optional (min-id nil) (accum '()))
"Get a list of accounts that user is following"
(let ((partial (api-client:sort-id< (get-following-accounts api-client:*client*
user-id
:max-id min-id))))
(if partial
(get-following user-id (tooter:id (first partial)) (append partial accum))
accum)))

View File

@ -1545,7 +1545,8 @@
:get-chat-messages
:get-chats
:post-on-chat
:create-new-chat))
:create-new-chat
:get-following))
(defpackage :api-client
(:use