git ssb

0+

Dominic / ssb-irc



Commit 5bc8ae7eb4551759e46280b098e8e739c7c6b977

tidy, and fix things

Dominic Tarr committed on 7/20/2017, 11:13:17 AM
Parent: bd5e4e2882df1a2c3e0823ff27646e6c18fc90d3

Files changed

index.jschanged
irc.jschanged
index.jsView
@@ -1,4 +1,5 @@
1 +'use strict'
12 var ssb = require('./ssb')
23 var IRC = require('./irc')
34 var pull = require('pull-stream')
45 //this should just wrap the stuff in util.js
@@ -23,26 +24,24 @@
2324 ssb.render(note, ssb.link(note.id, config))
2425 )
2526 }
2627
27- function next () {
28 + function next (err, arg) {
2829 if(--n) return
2930 //XXX: properly persist state with a flumeview?
30- console.log("STATE", state)
3131
3232 //make sure we have joined every channel
3333 for(var k in state.channels) {
3434 var channel = state.channels[k] === true ? k : state.channels[k]
35- console.log("JOIN", channel)
3635 IRC.join(irc, channel)
3736 }
3837
3938 //only notify about live posts.
4039 //this may cut out if the connection to IRC drops
41- //though, since
40 + //it should reconnect, but messages while disconnecting will be dropped.
4241
4342 pull(
44- sbot.createLogStream({live: true}),
43 + sbot.createLogStream({live: true, old: false}),
4544 pull.drain(function (msg) {
4645 if(msg.sync) return
4746 var a = ssb.match(state, msg)
4847 if(a.length)
@@ -53,5 +52,16 @@
5352 }
5453
5554
5655
56 +if(!module.parent) {
57 + require('ssb-client')(function (err, sbot) {
58 + exports.init(sbot, require('ssb-config'))
59 + })
5760
61 +}
62 +
63 +
64 +
65 +
66 +
67 +
irc.jsView
@@ -1,7 +1,14 @@
11 var IRC = module.exports = function (config, cb) {
2 +
23 var IRC = require('node-irc')
34 var conf = config.irc || {}
5 + console.log(
6 + "CONNECT",
7 + conf.host || 'irc.freenode.net',
8 + conf.port || 6667,
9 + conf.name || 'ssbbot_'
10 + )
411 var irc = new IRC(
512 conf.host || 'irc.freenode.net',
613 conf.port || 6667,
714 conf.name || 'ssbbot'
@@ -10,14 +17,15 @@
1017 irc.connect()
1118 irc.client.on('error', reconnect)
1219 irc.client.on('close', reconnect)
1320 var retry = false
14- function reconnect () {
21 + function reconnect (err) {
22 + console.log('reconnect...', err)
1523 if(retry) return
1624 retry = true
1725 setTimeout(connect, 10e3)
1826 }
19- })
27 + })()
2028 irc.on('ready', cb)
2129 irc.on('error', function () {
2230
2331 })

Built with git-ssb-web