Files: c4ecfe46560d18e9c365cb089ce2cd3cff71bfc1 / publish.js
831 bytesRaw
1 | var p = require('promptly'); |
2 | var chalk = require('chalk'); |
3 | var ssbClient = require('ssb-client'); |
4 | |
5 | var validator = function (value) { |
6 | if (value.length < 3) { |
7 | throw new Error('Your message is too short, type again.'); |
8 | } |
9 | return value; |
10 | }; |
11 | |
12 | var publishMessage = function () { |
13 | ssbClient(function (err, sbot) { |
14 | if (err) { |
15 | throw err; |
16 | } |
17 | p.prompt(chalk.cyan('Type a message in markdown and press [Enter] to publish:'), {validator: validator}, function (err, value) { |
18 | if (err) { |
19 | throw err; |
20 | } |
21 | sbot.publish({ |
22 | type: 'post', |
23 | text: value |
24 | }, function (err, msg) { |
25 | if (err) { |
26 | throw err; |
27 | } |
28 | console.log('You published: ' + msg.value.content.text + ' to Scuttlebot'); |
29 | process.exit(1); |
30 | }); |
31 | }); |
32 | }); |
33 | }; |
34 | |
35 | publishMessage(); |
36 |
Built with git-ssb-web