@@ -5591,12 +5591,13 @@ IO.register( 'rawinput', function spamDetection ( msgObj ) {
5591
5591
return ;
5592
5592
}
5593
5593
5594
- var usrid = msgObj . user_id ;
5594
+ var usrid = msgObj . user_id ,
5595
+ message = IO . decodehtmlEntities ( msgObj . content ) ;
5596
+
5595
5597
//there is a heavy assumption that all users who post a message here have
5596
5598
// been registered by the bot
5597
5599
var user = bot . users [ usrid ] ;
5598
- //since it's still in testing, it's rigged to respond to me (Zirak, 617762)
5599
- if ( usrid !== 617762 && ( bot . isOwner ( usrid ) || user . reputation > 1000 ) ) {
5600
+ if ( legitMessage ( ) ) {
5600
5601
return ;
5601
5602
}
5602
5603
@@ -5605,23 +5606,35 @@ IO.register( 'rawinput', function spamDetection ( msgObj ) {
5605
5606
var query = '#chat .monologue.user-{0} .content' . supplant ( usrid ) ,
5606
5607
userMessages = document . querySelectorAll ( query ) ;
5607
5608
5608
- var exactMatches = Array . filter ( userMessages , function ( content ) {
5609
- var msgid = ( / \d + / ) . exec ( content . parentNode . id ) [ 0 ] ;
5610
- return msgid < msgObj . message_id &&
5611
- content . innerHTML === msgObj . content ;
5612
- } ) ;
5609
+ var exactMatches = Array . filter ( userMessages , filterMessage ) ;
5613
5610
5614
5611
if ( ! exactMatches . length ) {
5615
5612
return ;
5616
5613
}
5617
- bot . log ( exactMatches , msgObj . content , 'spam detection matches' ) ;
5614
+ bot . log ( exactMatches , message , 'spam detection matches' ) ;
5618
5615
5619
5616
var reply = 'Please don\'t post the same thing more than once in a short ' +
5620
5617
'period of time. If it\'s a question, try again in a few hours.' ;
5621
5618
5622
5619
bot . adapter . out . add (
5623
5620
bot . adapter . reply ( msgObj . user_name ) + " " + reply ,
5624
5621
msgObj . room_id ) ;
5622
+
5623
+ function filterMessage ( content ) {
5624
+ var msgid = ( / \d + / ) . exec ( content . parentNode . id ) [ 0 ] ;
5625
+ return msgid < msgObj . message_id &&
5626
+ content . innerHTML === message ;
5627
+ }
5628
+ function legitMessage ( ) {
5629
+ //since it's still in testing, it should respond to me (Zirak, 617762)
5630
+ if ( usrid === 617762 ) {
5631
+ return false ;
5632
+ }
5633
+ //these are the actual filters
5634
+ return message . length < 50 &&
5635
+ bot . isOwner ( usrid ) ||
5636
+ user . reputation > 1000
5637
+ }
5625
5638
} ) ;
5626
5639
5627
5640
;
0 commit comments