Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit a69bb2c

Browse files
author
Zirak
committed
Community commands can now give informative messages
When you invoke a community command, it can now be configured with a template to tell you what the command does. Added it to ban, die, summon and unsommum. Fixes #228.
1 parent 88f6a35 commit a69bb2c

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

master.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,9 @@ bot.CommunityCommand = function ( command, req ) {
11061106
old_execute = cmd.exec,
11071107
old_canUse = cmd.canUse;
11081108

1109+
var pendingMessage = command.pendingMessage ||
1110+
'Already registered; still need {0} more';
1111+
console.log( command.pendingMessage, pendingMessage );
11091112
req = req || 2;
11101113

11111114
cmd.canUse = function () {
@@ -1145,7 +1148,7 @@ bot.CommunityCommand = function ( command, req ) {
11451148
needed -= 1;
11461149

11471150
if ( needed > 0 ) {
1148-
return 'Registered; need {0} more to execute'.supplant( needed );
1151+
return pendingMessage.supplant( needed );
11491152
}
11501153

11511154
bot.log( 'should execute' );
@@ -2265,12 +2268,13 @@ Object.iterate( commands, function ( cmdName, fun ) {
22652268
use : privilegedCommands[ cmdName ] ? 'OWNER' : 'ALL'
22662269
},
22672270
description : descriptions[ cmdName ],
2271+
pendingMessage: fun.pendingMessage,
22682272
unTellable : unTellable[ cmdName ],
2269-
async : commands[ cmdName ].async
2273+
async : fun.async
22702274
};
22712275

22722276
if ( communal[cmdName] ) {
2273-
cmd = bot.CommunityCommand( cmd );
2277+
cmd = bot.CommunityCommand( cmd, fun.invokeReq );
22742278
}
22752279
bot.addCommand( cmd );
22762280
});
@@ -3473,7 +3477,8 @@ var ban = {
34733477

34743478
permissions : { del : 'NONE', use : 'OWNER' },
34753479
description : 'Bans a user from using me. Lacking arguments, prints the ' +
3476-
'ban list. `/ban [usr_id|usr_name]`'
3480+
'ban list. `/ban [usr_id|usr_name]`',
3481+
pendingMessage : 'The user will be thrown into mindjail in {0} more invocations'
34773482
};
34783483

34793484
var unban = {
@@ -5097,6 +5102,7 @@ bot.addCommand(bot.CommunityCommand({
50975102
},
50985103
permissions : { del : 'NONE', use : 'OWNER' },
50995104
description : 'Kills me :(',
5105+
pendingMessage : 'I will shut up after {0} more invocations.'
51005106
}));
51015107

51025108
;
@@ -5959,7 +5965,8 @@ bot.addCommand( bot.CommunityCommand({
59595965
use : 'OWNER'
59605966
},
59615967
description : 'Say boopidi bee and in the room I shall be. '+
5962-
'`/summon roomid`'
5968+
'`/summon roomid`',
5969+
pendingMessage: 'I will appear in that room after {0} more invocation(s)'
59635970
}));
59645971

59655972
bot.addCommand( bot.CommunityCommand({
@@ -5970,7 +5977,8 @@ bot.addCommand( bot.CommunityCommand({
59705977
use : 'OWNER'
59715978
},
59725979
description : 'Chant zippidi lepat and from the room I shall depart. ' +
5973-
'`/unsummon [roomid=your_roomid]`'
5980+
'`/unsummon [roomid=your_roomid]`',
5981+
pendingMessage: 'I will leave this room after {0} more invocation(s)'
59745982
}));
59755983

59765984
})();

master.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/bot.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ bot.CommunityCommand = function ( command, req ) {
392392
old_execute = cmd.exec,
393393
old_canUse = cmd.canUse;
394394

395+
var pendingMessage = command.pendingMessage ||
396+
'Already registered; still need {0} more';
397+
console.log( command.pendingMessage, pendingMessage );
395398
req = req || 2;
396399

397400
cmd.canUse = function () {
@@ -431,7 +434,7 @@ bot.CommunityCommand = function ( command, req ) {
431434
needed -= 1;
432435

433436
if ( needed > 0 ) {
434-
return 'Registered; need {0} more to execute'.supplant( needed );
437+
return pendingMessage.supplant( needed );
435438
}
436439

437440
bot.log( 'should execute' );

source/commands.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,13 @@ Object.iterate( commands, function ( cmdName, fun ) {
278278
use : privilegedCommands[ cmdName ] ? 'OWNER' : 'ALL'
279279
},
280280
description : descriptions[ cmdName ],
281+
pendingMessage: fun.pendingMessage,
281282
unTellable : unTellable[ cmdName ],
282-
async : commands[ cmdName ].async
283+
async : fun.async
283284
};
284285

285286
if ( communal[cmdName] ) {
286-
cmd = bot.CommunityCommand( cmd );
287+
cmd = bot.CommunityCommand( cmd, fun.invokeReq );
287288
}
288289
bot.addCommand( cmd );
289290
});

source/plugins/ban.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ var ban = {
8282

8383
permissions : { del : 'NONE', use : 'OWNER' },
8484
description : 'Bans a user from using me. Lacking arguments, prints the ' +
85-
'ban list. `/ban [usr_id|usr_name]`'
85+
'ban list. `/ban [usr_id|usr_name]`',
86+
pendingMessage : 'The user will be thrown into mindjail in {0} more invocations'
8687
};
8788

8889
var unban = {

source/plugins/life.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ bot.addCommand(bot.CommunityCommand({
2424
},
2525
permissions : { del : 'NONE', use : 'OWNER' },
2626
description : 'Kills me :(',
27+
pendingMessage : 'I will shut up after {0} more invocations.'
2728
}));

source/plugins/summon.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ bot.addCommand( bot.CommunityCommand({
4444
use : 'OWNER'
4545
},
4646
description : 'Say boopidi bee and in the room I shall be. '+
47-
'`/summon roomid`'
47+
'`/summon roomid`',
48+
pendingMessage: 'I will appear in that room after {0} more invocation(s)'
4849
}));
4950

5051
bot.addCommand( bot.CommunityCommand({
@@ -55,7 +56,8 @@ bot.addCommand( bot.CommunityCommand({
5556
use : 'OWNER'
5657
},
5758
description : 'Chant zippidi lepat and from the room I shall depart. ' +
58-
'`/unsummon [roomid=your_roomid]`'
59+
'`/unsummon [roomid=your_roomid]`',
60+
pendingMessage: 'I will leave this room after {0} more invocation(s)'
5961
}));
6062

6163
})();

0 commit comments

Comments
 (0)