git ssb

0+

cel / ssb-clingy



Tree: cf5d38aee809a0a3f030b530894c015dea298200

Files: cf5d38aee809a0a3f030b530894c015dea298200 / index.js

858 bytesRaw
1// Clingy Plugin
2//
3// Will follow any connecting id unless already following
4exports.name = 'clingy'
5exports.version = '1.1.1'
6exports.manifest = {}
7
8exports.init = (api, opts) => {
9 api.on('rpc:connect', function (rpc, args) {
10 if (api.id === rpc.id) return
11
12 console.log("connection from: ", rpc.id)
13
14 var our_id = api.whoami().id
15 var connecting_id = rpc.id
16
17 api.friends.isFollowing({source: our_id, dest: connecting_id}, (err, following) => {
18 if (following) {
19 console.log("already following:", connecting_id)
20 } else {
21 // Yay more friendssss
22 console.log("stranger! New friend :3", connecting_id)
23
24 api.publish({
25 type: "contact",
26 contact: connecting_id,
27 following: true
28 }, () => {
29 console.log("Followed", connecting_id)
30 })
31 }
32 })
33 })
34}
35

Built with git-ssb-web