mastodonHandler extends Mastodon
parent
baf1e2cc48
commit
50d1dd7e17
@ -1,20 +1,18 @@
|
||||
import Mastodon from "mastodon-api";
|
||||
import fs from "fs";
|
||||
|
||||
export class MastodonHandler{
|
||||
constructor(baseUrl, token) {
|
||||
this.client = new Mastodon({
|
||||
api_url: `${baseUrl}/api/v1/`,
|
||||
access_token: token,
|
||||
})
|
||||
}
|
||||
export class MastodonHandler extends Mastodon{
|
||||
postStatus(status){
|
||||
this.client.post('statuses', {status: status}).then((resp) => console.log(resp.data))
|
||||
this.post('statuses', {status: status})
|
||||
.then(console.log("status posted => "))
|
||||
.then((resp) => console.log(resp.data));
|
||||
}
|
||||
postMedia(status, mediaPath){
|
||||
this.client.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => {
|
||||
this.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => {
|
||||
let id = resp.data.id;
|
||||
this.client.post('statuses', { status: status, media_ids: [id] }).then((resp) => console.log(resp.data))
|
||||
this.post('statuses', { status: status, media_ids: [id] })
|
||||
.then(console.log("media posted => "))
|
||||
.then((resp) => console.log(resp.data));
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue