forked from Zirak/SO-ChatBot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
summon.js
60 lines (51 loc) · 1.14 KB
/
summon.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(function () {
"use strict";
var summon = function ( args ) {
var room = Number( args );
if ( !room ) {
return 'That aint no room I ever heard of! ' +
'`/help summon` for usage info';
}
bot.adapter.in.init( room );
};
var unsummon = function ( args, cb ) {
var room = args.content ? Number( args ) : args.get( 'room_id' );
if ( !room ) {
return 'That aint no room I ever heard of! ' +
'`/help unsummon` for usage info';
}
bot.adapter.in.leaveRoom( room, function ( err ) {
if ( err === 'base_room' ) {
finish( 'I can\'t leave my home.' );
}
});
function finish ( res ) {
if ( cb && cb.call ) {
cb( res );
}
else {
args.reply( res );
}
}
};
bot.addCommand( bot.CommunityCommand({
name : 'summon',
fun : summon,
permissions : {
del : 'NONE',
use : 'OWNER'
},
description : 'Say boopidi bee and in the room I shall appear. '+
'`/summon roomid`'
}));
bot.addCommand( bot.CommunityCommand({
name : 'unsummon',
fun : unsummon,
permissions : {
del : 'NONE',
use : 'OWNER'
},
description : 'Chant zippidi dee and from the room I shall take my leave. ' +
'`/unsummon [roomid=your_roomid]`'
}));
})();