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

Commit 011c57c

Browse files
Sean McNamaraSean McNamara
authored andcommitted
Build recent changes.
1 parent 83e41ac commit 011c57c

File tree

2 files changed

+74
-114
lines changed

2 files changed

+74
-114
lines changed

master.js

Lines changed: 70 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ var bot = window.bot = {
681681

682682
//tell the user he's banned only if he hasn't already been told
683683
if ( !this.banlist[id].told ) {
684-
msg.reply( 'You iz in mindjail' );
684+
//msg.reply( 'You iz in mindjail' );
685685
this.banlist[ id ].told = true;
686686
}
687687
return;
@@ -1017,6 +1017,7 @@ bot.Command = function ( cmd ) {
10171017
cmd.del = function () {
10181018
bot.info.forgotten += 1;
10191019
delete bot.commands[ cmd.name ];
1020+
bot.commandDictionary.trie.del(cmd.name);
10201021
};
10211022

10221023
return cmd;
@@ -1539,6 +1540,24 @@ TrieNode.prototype.add = function( word ) {
15391540
node.word = word;
15401541
};
15411542

1543+
TrieNode.prototype.del = function(word, i) {
1544+
i = i || 0;
1545+
var node = this;
1546+
var char = word[i++];
1547+
1548+
// recursively delete all trie nodes that are left empty after removing the command from the leaf
1549+
if (node.children[char]) {
1550+
node.children[char].del(word, i);
1551+
if (Object.keys(node.children[char].children).length === 0 && node.children[char].word === null) {
1552+
delete node.children[char];
1553+
}
1554+
}
1555+
1556+
if (node.word === word) {
1557+
node.word = null;
1558+
}
1559+
}
1560+
15421561
//Having a small maxCost will increase performance greatly, experiment with
15431562
//values of 1-3
15441563
function SuggestionDictionary ( maxCost ) {
@@ -2435,13 +2454,16 @@ bot.adapter = {
24352454
//not a necessary function, used in here to set some variables
24362455
init : function () {
24372456
var fkey = document.getElementById( 'fkey' );
2457+
//produces http://chat.stackexchange.com/?tab=site&host=superuser.com
2458+
var pathToHostSite = document.getElementById('siterooms').href;
24382459
if ( !fkey ) {
24392460
console.error( 'bot.adapter could not find fkey; aborting' );
24402461
return;
24412462
}
24422463
this.fkey = fkey.value;
24432464
this.roomid = Number( /\d+/.exec(location)[0] );
2444-
this.site = /chat\.(\w+)/.exec( location )[ 1 ];
2465+
//gets the end of the pathToHostSite var (everything after 2nd equals)
2466+
this.site = /[a-z]*\.com$/.exec(pathToHostSite)[0];
24452467
this.user_id = CHAT.user.current().id;
24462468

24472469
this.in.init();
@@ -3010,33 +3032,6 @@ bot.listen(
30103032
bot.personality.apologize, bot.personality );
30113033
bot.listen( /^bitch/i, bot.personality.bitch, bot.personality );
30123034

3013-
;
3014-
(function () {
3015-
var hammers = {
3016-
STOP : 'HAMMERTIME!',
3017-
STAHP : 'HAMMAHTIME!',
3018-
HALT : 'HAMMERZEIT!',
3019-
STOY : 'ZABIVAT\' VREMYA!',
3020-
CAESUM: 'MALLEUS TEMPUS!'
3021-
};
3022-
3023-
// /(STOP|STAHP|...)[\.!\?]?$/
3024-
var re = new RegExp(
3025-
'(' +
3026-
Object.keys(hammers).map(RegExp.escape).join('|') +
3027-
')[\\.!?]?$' );
3028-
3029-
IO.register( 'input', function STOP ( msgObj ) {
3030-
var sentence = msgObj.content.toUpperCase(),
3031-
res = re.exec( sentence );
3032-
3033-
if ( res ) {
3034-
bot.adapter.out.add( hammers[res[1]], msgObj.room_id );
3035-
}
3036-
});
3037-
3038-
})();
3039-
30403035
;
30413036
//solves #86, mostly written by @Shmiddty
30423037
(function () {
@@ -3257,8 +3252,6 @@ IO.register( 'input', function afkInputListener ( msgObj ) {
32573252

32583253
})();
32593254

3260-
;
3261-
32623255
;
32633256
(function () {
32643257
"use strict";
@@ -4204,8 +4197,6 @@ IO.register( 'input', function eyesThighs ( msgObj ) {
42044197

42054198
})();
42064199

4207-
;
4208-
42094200
;
42104201
(function () {
42114202
var findCommand = function ( args ) {
@@ -4267,8 +4258,6 @@ bot.addCommand({
42674258
});
42684259
})();
42694260

4270-
;
4271-
42724261
;
42734262
//listener to help decide which Firefly episode to watch
42744263

@@ -4284,6 +4273,24 @@ bot.listen( /(which |what |give me a )?firefly( episode)?/i, function ( msg ) {
42844273
return 'Episode {0} - {1}'.supplant(r + 1, names[r]);
42854274
});
42864275

4276+
;
4277+
(function () {
4278+
"use strict";
4279+
//Forgets all the users it's seen.
4280+
4281+
bot.addCommand({
4282+
name : 'forgetSeen',
4283+
fun : function ( args ) {
4284+
bot.memory.get('users').length = 0;
4285+
},
4286+
permission : {
4287+
del : 'NONE',
4288+
use : 'OWNER'
4289+
},
4290+
description : 'Gives the bot a serious case of amnesia. Who are you again? (Only wipes out the list of known users)'
4291+
});
4292+
}());
4293+
42874294
;
42884295
// issue #51 https://github.com/Zirak/SO-ChatBot/issues/51
42894296

@@ -5023,8 +5030,6 @@ bot.addCommand({
50235030

50245031
})();
50255032

5026-
;
5027-
50285033
;
50295034
(function () {
50305035
"use strict";
@@ -5265,8 +5270,6 @@ bot.addCommand({
52655270

52665271
})();
52675272

5268-
;
5269-
52705273
;
52715274
(function () {
52725275
"use strict";
@@ -5442,8 +5445,6 @@ bot.addCommand({
54425445

54435446
})();
54445447

5445-
;
5446-
54475448
;
54485449
(function () {
54495450

@@ -5836,8 +5837,6 @@ bot.addCommand({
58365837

58375838
})();
58385839

5839-
;
5840-
58415840
;
58425841
(function () {
58435842
var specParts;
@@ -5989,6 +5988,33 @@ bot.addCommand(statsCmd);
59895988

59905989
}());
59915990

5991+
;
5992+
(function () {
5993+
var hammers = {
5994+
STOP : 'HAMMERTIME!',
5995+
STAHP : 'HAMMAHTIME!',
5996+
HALT : 'HAMMERZEIT!',
5997+
STOY : 'ZABIVAT\' VREMYA!',
5998+
CAESUM: 'MALLEUS TEMPUS!'
5999+
};
6000+
6001+
// /(STOP|STAHP|...)[\.!\?]?$/
6002+
var re = new RegExp(
6003+
'(' +
6004+
Object.keys(hammers).map(RegExp.escape).join('|') +
6005+
')[\\.!?]?$' );
6006+
6007+
IO.register( 'input', function STOP ( msgObj ) {
6008+
var sentence = msgObj.content.toUpperCase(),
6009+
res = re.exec( sentence );
6010+
6011+
if ( res ) {
6012+
bot.adapter.out.add( hammers[res[1]], msgObj.room_id );
6013+
}
6014+
});
6015+
6016+
})();
6017+
59926018
;
59936019
(function () {
59946020
/*
@@ -6066,66 +6092,6 @@ function get_message_link ( message ) {
60666092
}());
60676093

60686094
;
6069-
(function () {
6070-
"use strict";
6071-
6072-
var summon = function ( args ) {
6073-
var room = Number( args );
6074-
6075-
if ( !room ) {
6076-
return 'That aint no room I ever heard of! ' +
6077-
'`/help summon` for usage info';
6078-
}
6079-
6080-
bot.adapter.in.init( room );
6081-
};
6082-
var unsummon = function ( args, cb ) {
6083-
var room = args.content ? Number( args ) : args.get( 'room_id' );
6084-
6085-
if ( !room ) {
6086-
return 'That aint no room I ever heard of! ' +
6087-
'`/help unsummon` for usage info';
6088-
}
6089-
6090-
bot.adapter.in.leaveRoom( room, function ( err ) {
6091-
if ( err === 'base_room' ) {
6092-
finish( 'I can\'t leave my home.' );
6093-
}
6094-
});
6095-
6096-
function finish ( res ) {
6097-
if ( cb && cb.call ) {
6098-
cb( res );
6099-
}
6100-
else {
6101-
args.reply( res );
6102-
}
6103-
}
6104-
};
6105-
6106-
bot.addCommand( bot.CommunityCommand({
6107-
name : 'summon',
6108-
fun : summon,
6109-
permissions : {
6110-
del : 'NONE',
6111-
use : 'OWNER'
6112-
},
6113-
description : 'Say boopidi bee and in the room I shall appear. '+
6114-
'`/summon roomid`'
6115-
}));
6116-
6117-
bot.addCommand( bot.CommunityCommand({
6118-
name : 'unsummon',
6119-
fun : unsummon,
6120-
permissions : {
6121-
del : 'NONE',
6122-
use : 'OWNER'
6123-
},
6124-
description : 'Chant zippidi dee and from the room I shall take my leave. ' +
6125-
'`/unsummon [roomid=your_roomid]`'
6126-
}));
6127-
6128-
})();
61296095

61306096
;
61316097
(function () {
@@ -6557,8 +6523,6 @@ bot.addCommand({
65576523

65586524
})();
65596525

6560-
;
6561-
65626526
;
65636527
IO.register( 'input', function ( msgObj ) {
65646528
if ( msgObj.user_id === 1386886 && Math.random() < 0.005 ) {
@@ -6846,11 +6810,7 @@ bot.addCommand({
68466810
(function () {
68476811
"use strict";
68486812

6849-
var message = "Welcome to the JavaScript chat! Please review the " +
6850-
bot.adapter.link(
6851-
"room pseudo-rules",
6852-
"http://rlemon.github.com/so-chat-javascript-rules/" ) + ". " +
6853-
"Please don't ask if you can ask or if anyone's around; just ask " +
6813+
var message = "Welcome to the Root Access chat for Super Users! Please don't ask if you can ask or if anyone's around; just ask " +
68546814
"your question, and if anyone's free and interested they'll help.";
68556815

68566816
function welcome ( name ) {

0 commit comments

Comments
 (0)