Created
February 5, 2023 18:05
-
-
Save macdonst/cee3006a511f31414d14a268ae35c817 to your computer and use it in GitHub Desktop.
Post a message to Mastodon
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
import Meg from 'megalodon' | |
const { default: generator } = Meg | |
// switch to your mastodon server | |
const BASE_URL = 'https://mastodon.online/' | |
const access_token = process.env.MASTODON_TOKEN | |
export async function handler (event) { | |
const {title, link, description} = JSON.parse(event.Records[0].Sns.Message) | |
const toot = `${title} | |
${description} | |
${link} | |
` | |
const client = generator('mastodon', BASE_URL, access_token) | |
console.log(toot) | |
const res = await client.postStatus(toot) | |
console.log(res.data) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment