-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathssb-clingy.js
More file actions
34 lines (31 loc) · 789 Bytes
/
Copy pathssb-clingy.js
File metadata and controls
34 lines (31 loc) · 789 Bytes
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
module.exports = function (api, opts) {
api.auth.hook(function (fn, args) {
var connecting_id = args[0]
var our_id = api.whoami().id
var cb = args[1]
api.friends.isFollowing({source: our_id, dest: connecting_id}, function(err, following)
{
if(following)
{
console.log("already following:", connecting_id)
cb(null)
}
else
{
// Yay more friendssss
console.log("stranger! New friend :3", connecting_id)
api.publish({
type: "contact",
contact: connecting_id,
following: true
}, function(){
console.log("Followed", connecting_id)
cb(null)
})
}
})
})
}