Commit 37bc14fd6c074878351cfb7c4b80d24eebfc5b83
inital commit
Joran committed on 6/21/2019, 9:23:26 AMFiles changed
.gitignore | added |
Readme.md | added |
index.js | added |
package.json | added |
Readme.md | ||
---|---|---|
@@ -1,0 +1,33 @@ | ||
1 … | +# ssb-clingy | |
2 … | + | |
3 … | +Behaviour change plugin for scuttlebutt - follows back anyone who manages to connect | |
4 … | + | |
5 … | +## Install | |
6 … | + | |
7 … | +```sh | |
8 … | +ssb-server plugin.install ssb-clingy | |
9 … | +``` | |
10 … | + | |
11 … | + | |
12 … | +```javascript | |
13 … | +// add plugins | |
14 … | +Server | |
15 … | + .use(require('ssb-clingy')) | |
16 … | + .use(require('ssb-gossip')) | |
17 … | + .use(require('ssb-replicate')) | |
18 … | + .use(require('ssb-friends')) | |
19 … | + ... | |
20 … | + | |
21 … | +var server = Server(config) | |
22 … | +``` | |
23 … | + | |
24 … | +## TODO | |
25 … | + | |
26 … | +- [x] follow back strangers | |
27 … | +- [ ] filter for blocks | |
28 … | +- [ ] only follow people with no friends? | |
29 … | + | |
30 … | + | |
31 … | +## License | |
32 … | + | |
33 … | +MIT |
index.js | ||
---|---|---|
@@ -1,0 +1,34 @@ | ||
1 … | +// Clingy Plugin | |
2 … | +// | |
3 … | +// Will follow any connecting id unless already following | |
4 … | +module.exports = function (api, opts) { | |
5 … | + api.auth.hook(function (fn, args) { | |
6 … | + var connecting_id = args[0] | |
7 … | + var our_id = api.whoami().id | |
8 … | + var cb = args[1] | |
9 … | + | |
10 … | + api.friends.isFollowing({source: our_id, dest: connecting_id}, function(err, following) | |
11 … | + { | |
12 … | + if(following) | |
13 … | + { | |
14 … | + console.log("already following:", connecting_id) | |
15 … | + cb(null, {allow: null, deny: null}) | |
16 … | + } | |
17 … | + else | |
18 … | + { | |
19 … | + // Yay more friendssss | |
20 … | + console.log("stranger! New friend :3", connecting_id) | |
21 … | + | |
22 … | + api.publish({ | |
23 … | + type: "contact", | |
24 … | + contact: connecting_id, | |
25 … | + following: true | |
26 … | + }, function(){ | |
27 … | + console.log("Followed", connecting_id) | |
28 … | + | |
29 … | + cb(null, {allow: null, deny: null}) | |
30 … | + }) | |
31 … | + } | |
32 … | + }) | |
33 … | + }) | |
34 … | +} |
package.json | ||
---|---|---|
@@ -1,0 +1,22 @@ | ||
1 … | +{ | |
2 … | + "name": "ssb-clingy", | |
3 … | + "version": "1.0.0", | |
4 … | + "description": "Friendly follow-back behaviour for strangers who connect to a scuttlebutt instance", | |
5 … | + "main": "index.js", | |
6 … | + "scripts": { | |
7 … | + "test": "echo \"Error: no test specified\" && exit 1" | |
8 … | + }, | |
9 … | + "repository": { | |
10 … | + "type": "git", | |
11 … | + "url": "git+https://github.com/dangerousbeans/ssb-clingy.git" | |
12 … | + }, | |
13 … | + "keywords": [ | |
14 … | + "ssb" | |
15 … | + ], | |
16 … | + "author": "Joran Kikke", | |
17 … | + "license": "MIT", | |
18 … | + "bugs": { | |
19 … | + "url": "https://github.com/dangerousbeans/ssb-clingy/issues" | |
20 … | + }, | |
21 … | + "homepage": "https://github.com/dangerousbeans/ssb-clingy#readme" | |
22 … | +} |
Built with git-ssb-web