From eb847b7657c05942e7329a6ae7c04ad5e033dfdc Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Sat, 17 Jun 2017 13:18:49 +0700 Subject: [PATCH] Mastodon posting --- .gitignore | 1 + config.cson.example | 2 ++ main.coffee | 12 +++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 config.cson.example diff --git a/.gitignore b/.gitignore index 07e6e47..c5ad3fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +/config.cson diff --git a/config.cson.example b/config.cson.example new file mode 100644 index 0000000..8efc51a --- /dev/null +++ b/config.cson.example @@ -0,0 +1,2 @@ +access_token: "your-token-here" +api_url: "https://botsin.space/api/v1/" diff --git a/main.coffee b/main.coffee index 679497b..6026434 100644 --- a/main.coffee +++ b/main.coffee @@ -3,6 +3,13 @@ ImprovModel = require "./model" fs = require 'fs' CSON = require 'cson' glob = require 'glob' +Masto = require 'mastodon' + +config = CSON.parseCSONFile('config.cson') +Mastodon = new Masto({ + access_token: config.access_token + api_url: config.api_url +}) files = glob.sync('data/*.cson') spec = {} @@ -28,4 +35,7 @@ improv = new ImprovEngine(spec, { }) model = new ImprovModel -console.log improv.gen('description', model).trim() +description = improv.gen('description', model).trim() +Mastodon.post('statuses', { + status: description +})