noticeUwuzu v6.0@uwuzu1.5.4
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import type * as types from "types/types";
|
||||
|
||||
import config from "../../config.js";
|
||||
|
||||
export default async function followBack() {
|
||||
console.log("----------------");
|
||||
|
||||
// フォロワーを取得
|
||||
const resMe = await fetch(
|
||||
`https://${config.uwuzu.host}/api/me?token=${config.uwuzu.apiToken}`,
|
||||
{
|
||||
method: "GET",
|
||||
// uwuzu v1.5.4で/api/meのPOSTが死んでいるため簡易的にGET
|
||||
},
|
||||
);
|
||||
|
||||
const meData: types.meApi = await resMe.json();
|
||||
|
||||
console.log(`BOTプロフィール:${JSON.stringify(meData)}`);
|
||||
|
||||
const followers: Array<string> = meData.follower;
|
||||
|
||||
// フォロー
|
||||
for (let i = 0; i < followers.length; i++) {
|
||||
const followerItem = followers[i];
|
||||
|
||||
const resFollow = await fetch(
|
||||
`https://${config.uwuzu.host}/api/users/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
userid: followerItem,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const followData: types.followApi = await resFollow.json();
|
||||
|
||||
console.log(`フォロー:${JSON.stringify(followData)}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import followBack from "./follow.js";
|
||||
import unFollowBack from "./unfollow.js";
|
||||
|
||||
export default function follows() {
|
||||
unFollowBack();
|
||||
followBack();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import config from "../../config.js";
|
||||
import { meApi } from "types/types.js";
|
||||
|
||||
export default async function unFollowBack() {
|
||||
const profile: meApi = await
|
||||
(await fetch(`https://${config.uwuzu.host}/api/me`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
})
|
||||
})).json();
|
||||
|
||||
profile.followee.forEach(async (followUser: string) => {
|
||||
if (
|
||||
profile.follower[followUser] === undefined ||
|
||||
profile.follower[followUser] === null
|
||||
) {
|
||||
await fetch(`https://${config.uwuzu.host}/api/users/unfollow`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
userId: followUser,
|
||||
}),
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user