git ssb

3+

ev / starboard



Commit 0ff0dad7d66f96834c67caef86f53063e79f2c68

update deps and add feed reader that accepts post number and type arguments

Ev Bogue committed on 9/25/2017, 3:00:46 AM
Parent: bd60141d3891ec1751467c99ed9b55fe8e68493b

Files changed

package.jsonchanged
x.jsadded
package.jsonView
@@ -3,15 +3,17 @@
33 "version": "1.0.0",
44 "description": "command line sbot",
55 "main": "publish.js",
66 "dependencies": {
7- "chalk": "^1.1.3",
8- "moment": "^2.15.0",
9- "promptly": "^2.1.0",
10- "pull-paramap": "^1.1.6",
11- "pull-stream": "^3.4.5",
12- "ssb-avatar": "^0.1.0",
13- "ssb-client": "^4.0.3"
7 + "chalk": "^2.1.0",
8 + "human-time": "^0.0.1",
9 + "moment": "^2.18.1",
10 + "pull-cat": "^1.1.11",
11 + "pull-paramap": "^1.2.2",
12 + "pull-stream": "^3.6.1",
13 + "ssb-avatar": "^0.2.0",
14 + "ssb-client": "^4.5.1",
15 + "ssb-signs": "^1.0.0"
1416 },
1517 "devDependencies": {},
1618 "scripts": {
1719 "test": "echo \"Error: no test specified\" && exit 1"
x.jsView
@@ -1,0 +1,57 @@
1 +var pull = require('pull-stream')
2 +var paramap = require('pull-paramap')
3 +var ssbClient = require('ssb-client')
4 +var chalk = require('chalk')
5 +var human = require('human-time')
6 +var avatar = require('ssb-avatar')
7 +
8 +var listMessages = function () {
9 + var number = process.argv[2]
10 + var type = process.argv[3]
11 +
12 + ssbClient(function (err, sbot) {
13 + if (err) throw err
14 + sbot.whoami(function getId(err, me) {
15 + if (err) throw err
16 + pull(
17 + sbot.messagesByType({
18 + type: type,
19 + limit: Number(number),
20 + reverse: true
21 + }),
22 + paramap(function getAvatar(msg, cb) {
23 + avatar(sbot, me.id, msg.value.author, function (err, avatar) {
24 + if (err) throw err
25 + msg.avatar = avatar
26 + cb(null, msg)
27 + })
28 + }),
29 + pull.drain(function (msg) {
30 + if (type === 'post') {
31 + console.log(
32 + chalk.cyan('@' + msg.avatar.name) +
33 + ' ' +
34 + msg.value.content.text +
35 + ' ' +
36 + chalk.dim(human(new Date(msg.value.timestamp)))
37 + )
38 + } else if (type === 'vote') {
39 + if (msg.value.content.vote.link) {
40 + console.log(
41 + chalk.cyan('@' + msg.avatar.name) +
42 + ' dug ' +
43 + msg.value.content.vote.link +
44 + ' ' +
45 + chalk.dim(human(new Date(msg.value.timestamp)))
46 + )
47 + }
48 + } else {
49 + console.log(msg.value.content)
50 + }
51 + })
52 + )
53 + })
54 + })
55 +}
56 +
57 +listMessages()

Built with git-ssb-web