WIP
This commit is contained in:
parent
f07baecee4
commit
c5e243337e
|
@ -2,7 +2,7 @@ import { rest, rootStatus } from '../../prepare'
|
||||||
import Logger from '../../utils/Logger'
|
import Logger from '../../utils/Logger'
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const content = process.argv[2]
|
const [,,content, visibility] = process.argv
|
||||||
if (!content) {
|
if (!content) {
|
||||||
Logger.error('require content')
|
Logger.error('require content')
|
||||||
return
|
return
|
||||||
|
@ -11,7 +11,7 @@ async function run() {
|
||||||
const status = await rest.postStatus({
|
const status = await rest.postStatus({
|
||||||
in_reply_to_id: rootStatus,
|
in_reply_to_id: rootStatus,
|
||||||
status: content,
|
status: content,
|
||||||
visibility: 'private'
|
visibility: visibility as any || 'direct'
|
||||||
})
|
})
|
||||||
Logger.info('action added', { id: status.id, tags: status.tags.map(t => t.name).reverse() })
|
Logger.info('action added', { id: status.id, tags: status.tags.map(t => t.name).reverse() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,32 @@ import { rest, rootStatus } from '../../prepare'
|
||||||
import Logger from '../../utils/Logger'
|
import Logger from '../../utils/Logger'
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const [,, file, title] = process.argv
|
const [,, file, title, visibility] = process.argv
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Logger.error('require file')
|
Logger.error('require file')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const post = async (in_reply_to_id: string, status: string) => rest.postStatus({
|
||||||
|
in_reply_to_id, status,
|
||||||
|
visibility: visibility as any || 'direct'
|
||||||
|
}).then(s => s.id)
|
||||||
|
|
||||||
const data = JSON.parse(fs.readFileSync(file, 'utf8'))
|
const data = JSON.parse(fs.readFileSync(file, 'utf8'))
|
||||||
const ok = data.map((l: any) => Object.entries(l).map(([lang, message]) => `[${lang}] ${message}`).join('\n'))
|
const folder = await post(rootStatus, title || file)
|
||||||
Logger.info('data', ok)
|
for (const row of data) {
|
||||||
/*
|
if (typeof row === 'string') {
|
||||||
const status = await rest.postStatus({
|
await post(folder, row)
|
||||||
in_reply_to_id: rootStatus,
|
} else if (typeof row === 'object') {
|
||||||
status: content,
|
const content = '\n' + Object.entries(row).map(([lang, message]) => `[${lang}] ${message}`).join('\n\n')
|
||||||
visibility: 'private'
|
const global = await post(folder, content)
|
||||||
})
|
for (const [lang, message] of Object.entries(row)) {
|
||||||
Logger.info('action added', { id: status.id, tags: status.tags.map(t => t.name).reverse() })*/
|
await post(global, `${message} #${lang}`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('bad type ' + typeof row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.info('data added', folder)
|
||||||
}
|
}
|
||||||
run()
|
run()
|
Loading…
Reference in New Issue