git ssb

3+

ev / starboard



Commit 14b1bdea5455da6d2f5f5f89c796ddff4c90dede

update short and add allshort programs

Ev Bogue committed on 10/1/2017, 4:27:38 PM
Parent: c4cb28adc9c1fbd67935b90d99e1b41dde251697

Files changed

short.jschanged
allshort.jsadded
short.jsView
@@ -30,9 +30,9 @@
3030 if (msg.value.content.type === 'post') {
3131 message = msg.value.content.text
3232 console.log(
3333 chalk.dim(msg.key) + ' | ' +
34- chalk.cyan('@' + msg.avatar.name) +
34 + chalk.cyan('@' + msg.avatar.name.substring(0, 15)) +
3535 ' ' +
3636 message.replace(/[\n\r]+/g, '').substring(0, 80) +'...' +
3737 ' ' +
3838 chalk.dim(human(new Date(msg.value.timestamp)))
allshort.jsView
@@ -1,0 +1,84 @@
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 +function render (msg) {
9 +
10 + if (msg.value.content.type === 'post') {
11 + message = msg.value.content.text
12 + console.log(
13 + chalk.dim(msg.key) + ' | ' +
14 + chalk.cyan('@' + msg.avatar.name.substring(0, 15)) +
15 + ' ' +
16 + message.replace(/[\n\r]+/g, '').substring(0, 80) +'...' +
17 + ' ' +
18 + chalk.dim(human(new Date(msg.value.timestamp)))
19 + )
20 + } else if (msg.value.content.type === 'vote') {
21 + if (msg.value.content.vote.link) {
22 + console.log(
23 + chalk.dim(msg.key) + ' | ' +
24 + chalk.cyan('@' + msg.avatar.name) +
25 + ' dug ' +
26 + msg.value.content.vote.link +
27 + ' ' +
28 + chalk.dim(human(new Date(msg.value.timestamp)))
29 + )
30 + }
31 + } else if (msg.value.content.type === 'contact') {
32 + if (msg.value.content.following = 'true') { exp = ' follows ' } else { exp = ' unfollows '}
33 + console.log(
34 + chalk.dim(msg.key) + ' | ' +
35 + chalk.cyan('@' + msg.avatar.name) + exp + msg.value.content.contact
36 + )
37 + }
38 + else {
39 + if (msg.value.content.type) {
40 + console.log(
41 + chalk.dim(msg.key) + ' | ' +
42 + chalk.cyan('@' + msg.avatar.name) + ' ' +
43 + msg.value.content.type
44 + )
45 + } else {
46 + console.log(
47 + chalk.dim(msg.key) + ' | ' +
48 + chalk.cyan('@' + msg.avatar.name) + ' ' +
49 + 'sent a private message'
50 + )
51 + }
52 + }
53 +}
54 +
55 +var listMessages = function () {
56 + var number = process.argv[2]
57 + var type = process.argv[3]
58 +
59 + ssbClient(function (err, sbot) {
60 + if (err) throw err
61 + sbot.whoami(function getId(err, me) {
62 + if (err) throw err
63 + pull(
64 + sbot.createLogStream({
65 + limit: Number(number) || 44,
66 + reverse: true
67 + }),
68 + paramap(function getAvatar(msg, cb) {
69 + avatar(sbot, me.id, msg.value.author, function (err, avatar) {
70 + if (err) throw err
71 + msg.avatar = avatar
72 + cb(null, msg)
73 + })
74 + }),
75 + pull.drain(function (msg) {
76 + render(msg)
77 + sbot.close()
78 + })
79 + )
80 + })
81 + })
82 +}
83 +
84 +listMessages()

Built with git-ssb-web