@@ -5103,8 +5103,16 @@ bot.addCommand(bot.CommunityCommand({
5103
5103
( function ( ) {
5104
5104
5105
5105
function mdn ( args , cb ) {
5106
- IO . jsonp . google (
5107
- args . toString ( ) + ' site:developer.mozilla.org' , finishCall ) ;
5106
+ var terms = args . toString ( ) . split ( / , \s * / g) ;
5107
+ var results = {
5108
+ unescapedUrls : [ ] ,
5109
+ formatted : [ ]
5110
+ } ;
5111
+
5112
+ terms . forEach ( function ( term ) {
5113
+ IO . jsonp . google (
5114
+ term + ' site:developer.mozilla.org' , finishCall ) ;
5115
+ } ) ;
5108
5116
5109
5117
function finishCall ( resp ) {
5110
5118
if ( resp . responseStatus !== 200 ) {
@@ -5114,9 +5122,26 @@ function mdn ( args, cb ) {
5114
5122
5115
5123
var result = resp . responseData . results [ 0 ] ;
5116
5124
bot . log ( result , '/mdn result' ) ;
5117
- finish ( result . url ) ;
5125
+
5126
+ var title = IO . decodehtmlEntities (
5127
+ result . titleNoFormatting . split ( ' -' ) [ 0 ] . trim ( )
5128
+ ) ;
5129
+
5130
+ results . formatted . push ( bot . adapter . link ( title , result . url ) ) ;
5131
+ results . unescapedUrls . push ( result . url ) ;
5132
+
5133
+ if ( results . formatted . length === terms . length ) {
5134
+ aggregatedResults ( ) ;
5135
+ }
5118
5136
}
5137
+ function aggregatedResults ( ) {
5138
+ var msg = results . formatted . join ( ', ' ) ;
5139
+ if ( msg . length > bot . adapter . maxLineLength ) {
5140
+ msg = results . unescapedUrls . join ( ', ' ) ;
5141
+ }
5119
5142
5143
+ finish ( msg ) ;
5144
+ }
5120
5145
function finish ( res ) {
5121
5146
if ( cb && cb . call ) {
5122
5147
cb ( res ) ;
0 commit comments