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