@@ -1259,7 +1259,7 @@ setTimeout(function () {
1259
1259
return ;
1260
1260
}
1261
1261
1262
- IO . injectScript ( 'https://raw.github .com/jashkenas/coffee-script/master/extras/coffee-script.js' ) ;
1262
+ IO . injectScript ( 'https://rawgithub .com/jashkenas/coffee-script/master/extras/coffee-script.js' ) ;
1263
1263
} , 1000 ) ;
1264
1264
1265
1265
//execute arbitrary js code in a relatively safe environment
@@ -1493,7 +1493,7 @@ var blob = new Blob( [workerCode], { type : 'application/javascript' } ),
1493
1493
codeUrl = window . URL . createObjectURL ( blob ) ;
1494
1494
1495
1495
return function ( code , arg , cb ) {
1496
- if ( arguments . length === 2 ) {
1496
+ if ( arguments . length === 2 ) {
1497
1497
cb = arg ;
1498
1498
arg = null ;
1499
1499
}
@@ -1502,7 +1502,7 @@ return function ( code, arg, cb ) {
1502
1502
timeout ;
1503
1503
1504
1504
worker . onmessage = function ( evt ) {
1505
- bot . log ( evt , 'eval worker.onmessage' ) ;
1505
+ bot . log ( evt , 'eval worker.onmessage' ) ;
1506
1506
1507
1507
var type = evt . data . event ;
1508
1508
@@ -1566,48 +1566,48 @@ bot.prettyEval = function ( code, arg, cb ) {
1566
1566
1567
1567
return bot . eval ( code , arg , finish ) ;
1568
1568
1569
- function finish ( err , answerObj ) {
1570
- if ( err ) {
1571
- cb ( err ) ;
1572
- }
1573
- else {
1574
- cb ( dressUpAnswer ( answerObj ) ) ;
1575
- }
1576
- }
1569
+ function finish ( err , answerObj ) {
1570
+ if ( err ) {
1571
+ cb ( err ) ;
1572
+ }
1573
+ else {
1574
+ cb ( dressUpAnswer ( answerObj ) ) ;
1575
+ }
1576
+ }
1577
1577
1578
- function dressUpAnswer ( answerObj ) {
1579
- bot . log ( answerObj , 'eval answerObj' ) ;
1580
- var answer = answerObj . answer ,
1581
- log = answerObj . log ,
1582
- result ;
1578
+ function dressUpAnswer ( answerObj ) {
1579
+ bot . log ( answerObj , 'eval answerObj' ) ;
1580
+ var answer = answerObj . answer ,
1581
+ log = answerObj . log ,
1582
+ result ;
1583
1583
1584
- if ( answer === undefined ) {
1585
- return 'Malformed output from web-worker. If you weren\'t just ' +
1586
- 'fooling around trying to break me, raise an issue or contact ' +
1587
- 'Zirak' ;
1588
- }
1584
+ if ( answer === undefined ) {
1585
+ return 'Malformed output from web-worker. If you weren\'t just ' +
1586
+ 'fooling around trying to break me, raise an issue or contact ' +
1587
+ 'Zirak' ;
1588
+ }
1589
1589
1590
- result = snipAndCodify ( answer ) ;
1590
+ result = snipAndCodify ( answer ) ;
1591
1591
1592
- if ( log && log . length ) {
1593
- result += ' Logged: ' + snipAndCodify ( log ) ;
1594
- }
1592
+ if ( log && log . length ) {
1593
+ result += ' Logged: ' + snipAndCodify ( log ) ;
1594
+ }
1595
1595
1596
- return result ;
1597
- }
1596
+ return result ;
1597
+ }
1598
1598
1599
- function snipAndCodify ( str ) {
1600
- var ret ;
1599
+ function snipAndCodify ( str ) {
1600
+ var ret ;
1601
1601
1602
- if ( str . length > 400 ) {
1603
- ret = '`' + str . slice ( 0 , 400 ) + '` (snip)' ;
1604
- }
1605
- else {
1606
- ret = '`' + str + '`' ;
1607
- }
1602
+ if ( str . length > 400 ) {
1603
+ ret = '`' + str . slice ( 0 , 400 ) + '` (snip)' ;
1604
+ }
1605
+ else {
1606
+ ret = '`' + str + '`' ;
1607
+ }
1608
1608
1609
- return ret ;
1610
- }
1609
+ return ret ;
1610
+ }
1611
1611
} ;
1612
1612
1613
1613
@@ -5757,24 +5757,26 @@ function substitute ( msg ) {
5757
5757
var messages ;
5758
5758
if ( msg . matches [ 5 ] ) {
5759
5759
messages = Array . from (
5760
- document . querySelectorAll ( '#message-' + msg . matches [ 5 ] + ' .content' ) ) ;
5760
+ document . querySelectorAll ( '#message-' + msg . matches [ 5 ] + ' .content' )
5761
+ ) ;
5761
5762
}
5762
5763
else {
5763
5764
messages = Array . from (
5764
- document . getElementsByClassName ( 'content' ) ) . reverse ( ) ;
5765
+ document . getElementsByClassName ( 'content' )
5766
+ ) . reverse ( ) ;
5765
5767
}
5766
5768
5767
5769
getMatchingMessage ( re , messages , msg . get ( 'message_id' ) , function ( err , message ) {
5768
- if ( err ) {
5769
- msg . reply ( err ) ;
5770
- return ;
5771
- }
5770
+ if ( err ) {
5771
+ msg . reply ( err ) ;
5772
+ return ;
5773
+ }
5772
5774
5773
5775
if ( ! message ) {
5774
5776
msg . reply (
5775
5777
'No matching message (are you sure we\'re in the right room?)'
5776
5778
) ;
5777
- return ;
5779
+ return ;
5778
5780
}
5779
5781
bot . log ( message , 'substitution found message' ) ;
5780
5782
@@ -5798,58 +5800,59 @@ function substitute ( msg ) {
5798
5800
}
5799
5801
5800
5802
function getMatchingMessage ( re , messages , onlyBefore , cb ) {
5801
- var arg = {
5802
- maxId : onlyBefore ,
5803
- pattern : re ,
5804
- messages : messages . map ( function ( el ) {
5805
- return {
5806
- id : Number ( el . parentElement . id . match ( / \d + / ) [ 0 ] ) ,
5807
- text : el . textContent
5808
- } ;
5809
- } )
5810
- } ;
5811
-
5812
- // the following function is passed to bot.eval, which means it will run in
5813
- //a different context. the only variable we get is ~arg~, because we pass it
5814
- //to bot.eval
5815
- // we do the skip and jump through bot.eval to avoid a ReDoS (#217).
5816
- var matcher = function ( ) {
5803
+ bot . log ( re , messages , onlyBefore , 'substitution getMatchingMessage args' ) ;
5804
+ var arg = {
5805
+ maxId : onlyBefore ,
5806
+ pattern : re ,
5807
+ messages : messages . map ( function ( el ) {
5808
+ return {
5809
+ id : Number ( el . parentElement . id . match ( / \d + / ) [ 0 ] ) ,
5810
+ text : el . textContent
5811
+ } ;
5812
+ } )
5813
+ } ;
5814
+
5815
+ // the following function is passed to bot.eval, which means it will run in
5816
+ //a different context. the only variable we get is ~arg~, because we pass it
5817
+ //to bot.eval
5818
+ // we do the skip and jump through bot.eval to avoid a ReDoS (#217).
5819
+ var matcher = function ( ) {
5817
5820
var arg = arguments [ 1 ] ,
5818
5821
matchIndex = null ;
5819
5822
5820
- arg . messages . some ( function ( msg , idx ) {
5821
- if ( msg . id < arg . maxId && arg . pattern . test ( msg . text ) ) {
5822
- matchIndex = idx ;
5823
- return true ;
5824
- }
5823
+ arg . messages . some ( function ( msg , idx ) {
5824
+ if ( msg . id < arg . maxId && arg . pattern . test ( msg . text ) ) {
5825
+ matchIndex = idx ;
5826
+ return true ;
5827
+ }
5825
5828
5826
- return false ;
5827
- } ) ;
5829
+ return false ;
5830
+ } ) ;
5828
5831
5829
- // remember we're inside bot.eval, final expression is the result.
5832
+ // remember we're inside bot.eval, final expression is the result.
5830
5833
// so it'll work well with minification, we have to create an expression
5831
5834
//which won't be removed
5832
5835
( function ( ) {
5833
5836
return matchIndex ;
5834
5837
} ) ( ) ;
5835
- } ;
5838
+ } ;
5836
5839
5837
5840
bot . eval ( matcher . stringContents ( ) , arg , function ( err , resp ) {
5838
5841
bot . log ( err , resp , 'substitution matcher response' ) ;
5839
5842
5840
- // meh
5841
- if ( err ) {
5842
- cb ( err ) ;
5843
- return ;
5844
- }
5843
+ // meh
5844
+ if ( err ) {
5845
+ cb ( err ) ;
5846
+ return ;
5847
+ }
5845
5848
5846
- var index = JSON . parse ( resp . answer ) ;
5847
- if ( Number ( index ) !== index ) {
5848
- return ;
5849
- }
5849
+ var index = JSON . parse ( resp . answer ) ;
5850
+ if ( Number ( index ) !== index ) {
5851
+ return ;
5852
+ }
5850
5853
5851
- cb ( null , messages [ index ] ) ;
5852
- } ) ;
5854
+ cb ( null , messages [ index ] ) ;
5855
+ } ) ;
5853
5856
}
5854
5857
5855
5858
// <a class="action-link" href="/transcript/message/msgid#msgid>...</a>
@@ -5867,8 +5870,8 @@ function getMessageLink ( message ) {
5867
5870
}
5868
5871
5869
5872
// <div class="content">
5870
- // <div class="partial"> ... </div>
5871
- // <a class="more-data" href="what we want">(see full text)</a>
5873
+ // <div class="partial"> ... </div>
5874
+ // <a class="more-data" href="what we want">(see full text)</a>
5872
5875
// </div>
5873
5876
function retrieveFullText ( message , cb ) {
5874
5877
var href = message . children [ 1 ] . href ;
0 commit comments