@@ -681,7 +681,7 @@ var bot = window.bot = {
681
681
682
682
//tell the user he's banned only if he hasn't already been told
683
683
if ( ! this . banlist [ id ] . told ) {
684
- msg . reply ( 'You iz in mindjail' ) ;
684
+ // msg.reply( 'You iz in mindjail' );
685
685
this . banlist [ id ] . told = true ;
686
686
}
687
687
return ;
@@ -1017,6 +1017,7 @@ bot.Command = function ( cmd ) {
1017
1017
cmd . del = function ( ) {
1018
1018
bot . info . forgotten += 1 ;
1019
1019
delete bot . commands [ cmd . name ] ;
1020
+ bot . commandDictionary . trie . del ( cmd . name ) ;
1020
1021
} ;
1021
1022
1022
1023
return cmd ;
@@ -1539,6 +1540,24 @@ TrieNode.prototype.add = function( word ) {
1539
1540
node . word = word ;
1540
1541
} ;
1541
1542
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
+
1542
1561
//Having a small maxCost will increase performance greatly, experiment with
1543
1562
//values of 1-3
1544
1563
function SuggestionDictionary ( maxCost ) {
@@ -2435,13 +2454,16 @@ bot.adapter = {
2435
2454
//not a necessary function, used in here to set some variables
2436
2455
init : function ( ) {
2437
2456
var fkey = document . getElementById ( 'fkey' ) ;
2457
+ //produces http://chat.stackexchange.com/?tab=site&host=superuser.com
2458
+ var pathToHostSite = document . getElementById ( 'siterooms' ) . href ;
2438
2459
if ( ! fkey ) {
2439
2460
console . error ( 'bot.adapter could not find fkey; aborting' ) ;
2440
2461
return ;
2441
2462
}
2442
2463
this . fkey = fkey . value ;
2443
2464
this . roomid = Number ( / \d + / . exec ( location ) [ 0 ] ) ;
2444
- this . site = / c h a t \. ( \w + ) / . exec ( location ) [ 1 ] ;
2465
+ //gets the end of the pathToHostSite var (everything after 2nd equals)
2466
+ this . site = / [ a - z ] * \. c o m $ / . exec ( pathToHostSite ) [ 0 ] ;
2445
2467
this . user_id = CHAT . user . current ( ) . id ;
2446
2468
2447
2469
this . in . init ( ) ;
@@ -3010,33 +3032,6 @@ bot.listen(
3010
3032
bot . personality . apologize , bot . personality ) ;
3011
3033
bot . listen ( / ^ b i t c h / i, bot . personality . bitch , bot . personality ) ;
3012
3034
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
-
3040
3035
;
3041
3036
//solves #86, mostly written by @Shmiddty
3042
3037
( function ( ) {
@@ -3257,8 +3252,6 @@ IO.register( 'input', function afkInputListener ( msgObj ) {
3257
3252
3258
3253
} ) ( ) ;
3259
3254
3260
- ;
3261
-
3262
3255
;
3263
3256
( function ( ) {
3264
3257
"use strict" ;
@@ -4204,8 +4197,6 @@ IO.register( 'input', function eyesThighs ( msgObj ) {
4204
4197
4205
4198
} ) ( ) ;
4206
4199
4207
- ;
4208
-
4209
4200
;
4210
4201
( function ( ) {
4211
4202
var findCommand = function ( args ) {
@@ -4267,8 +4258,6 @@ bot.addCommand({
4267
4258
} ) ;
4268
4259
} ) ( ) ;
4269
4260
4270
- ;
4271
-
4272
4261
;
4273
4262
//listener to help decide which Firefly episode to watch
4274
4263
@@ -4284,6 +4273,24 @@ bot.listen( /(which |what |give me a )?firefly( episode)?/i, function ( msg ) {
4284
4273
return 'Episode {0} - {1}' . supplant ( r + 1 , names [ r ] ) ;
4285
4274
} ) ;
4286
4275
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
+
4287
4294
;
4288
4295
// issue #51 https://github.com/Zirak/SO-ChatBot/issues/51
4289
4296
@@ -5023,8 +5030,6 @@ bot.addCommand({
5023
5030
5024
5031
} ) ( ) ;
5025
5032
5026
- ;
5027
-
5028
5033
;
5029
5034
( function ( ) {
5030
5035
"use strict" ;
@@ -5265,8 +5270,6 @@ bot.addCommand({
5265
5270
5266
5271
} ) ( ) ;
5267
5272
5268
- ;
5269
-
5270
5273
;
5271
5274
( function ( ) {
5272
5275
"use strict" ;
@@ -5442,8 +5445,6 @@ bot.addCommand({
5442
5445
5443
5446
} ) ( ) ;
5444
5447
5445
- ;
5446
-
5447
5448
;
5448
5449
( function ( ) {
5449
5450
@@ -5836,8 +5837,6 @@ bot.addCommand({
5836
5837
5837
5838
} ) ( ) ;
5838
5839
5839
- ;
5840
-
5841
5840
;
5842
5841
( function ( ) {
5843
5842
var specParts ;
@@ -5989,6 +5988,33 @@ bot.addCommand(statsCmd);
5989
5988
5990
5989
} ( ) ) ;
5991
5990
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
+
5992
6018
;
5993
6019
( function ( ) {
5994
6020
/*
@@ -6066,66 +6092,6 @@ function get_message_link ( message ) {
6066
6092
} ( ) ) ;
6067
6093
6068
6094
;
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
- } ) ( ) ;
6129
6095
6130
6096
;
6131
6097
( function ( ) {
@@ -6557,8 +6523,6 @@ bot.addCommand({
6557
6523
6558
6524
} ) ( ) ;
6559
6525
6560
- ;
6561
-
6562
6526
;
6563
6527
IO . register ( 'input' , function ( msgObj ) {
6564
6528
if ( msgObj . user_id === 1386886 && Math . random ( ) < 0.005 ) {
@@ -6846,11 +6810,7 @@ bot.addCommand({
6846
6810
( function ( ) {
6847
6811
"use strict" ;
6848
6812
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 " +
6854
6814
"your question, and if anyone's free and interested they'll help." ;
6855
6815
6856
6816
function welcome ( name ) {
0 commit comments