Last active
May 10, 2024 07:51
-
-
Save ltlapy/9ef88d770e76c858fd1b65398463c224 to your computer and use it in GitHub Desktop.
여러 명의 유저를 리스트에 추가하는 아이스크립트
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------- | |
// 아래 항목을 채우고 스크래치 패드에서 실행 | |
// 실행 전 API 리밋 해제 여부 반드시 확인 | |
// ---------------------------------- | |
let listId = "xxxxxxxxx" | |
let userHandles = [ | |
// @username | |
// @username@host | |
] | |
// --- 사용자 지정 항목 끝 --- | |
// region misc | |
let log = @(v) { <: v } | |
let getUser = @(handle) { | |
// log(`{handle}: 계정 정보를 가져옵니다...`) | |
var username = "" | |
var host = null | |
let handleSplit = handle.split("@") | |
username = handleSplit[1] | |
if (handleSplit.len == 3) { host = handleSplit[2] } | |
let user = Mk:api('users/show' { | |
host: host | |
username: username | |
}) | |
if (Core:type(user) == "error") { | |
log(`{handle}: 유저를 찾을 수 없습니다.`) | |
log(user.info) | |
return null | |
} | |
// log(`{handle}: 유저를 찾았습니다.`) | |
return user | |
} | |
// endregion | |
var okCnt = 0; | |
each (let userHandle, userHandles) { | |
log(`{handle} 을(를) 리스트에 추가합니다...`) | |
let user = getUser(userHandle) | |
if (user == null) { | |
continue | |
} | |
let res = Mk:api('users/lists/push' { | |
listId: listId | |
userId: user.id | |
}) | |
if (Core:type(res) == "error") { | |
log(`{userHandle} 을(를) 리스트에 추가할 수 없습니다.`) | |
log(res.info) | |
} else { | |
okCnt += 1 | |
} | |
} | |
<: `{userHandles.len}개 가운데 {okCnt} 건의 계정이 삽입되었습니다` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment