You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
743 B
22 lines
743 B
import Mastodon from "mastodon-api";
|
|
import fs from "fs";
|
|
|
|
export class MastodonHandler extends Mastodon{
|
|
postStatus(status){
|
|
this.post('statuses', {status: status}).then((resp) => {
|
|
console.log("status posted => ");
|
|
console.log(resp.data);
|
|
});
|
|
}
|
|
postMedia(status, mediaPath){
|
|
this.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => {
|
|
let id = resp.data.id;
|
|
console.log("media uploaded => ");
|
|
console.log(resp.data);
|
|
this.post('statuses', { status: status, media_ids: [id] }).then((resp) => {
|
|
console.log("media posted => ");
|
|
console.log(resp.data);
|
|
});
|
|
});
|
|
}
|
|
} |