@ -2388,13 +2388,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
} )
} )
. service ( 'AppInlineBotsManager' , function ( $rootScope , Storage , MtpApiManager , AppMessagesManager , AppDocsManager , AppPhotosManager , RichTextProcessor , AppUsersManager ) {
. service ( 'AppInlineBotsManager' , function ( $rootScope , Storage , MtpApiManager , AppMessagesManager , AppDocsManager , AppPhotosManager , RichTextProcessor , AppUsersManager , AppPeersManager ) {
var inlineResults = { } ;
var inlineResults = { } ;
return {
return {
sendInlineResult : sendInlineResult ,
sendInlineResult : sendInlineResult ,
regroupWrappedResults : regroupWrappedResults ,
regroupWrappedResults : regroupWrappedResults ,
switchToPM : switchToPM ,
getInlineResults : getInlineResults ,
getInlineResults : getInlineResults ,
getPopularBots : getPopularBots
getPopularBots : getPopularBots
} ;
} ;
@ -2450,9 +2451,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} ) ;
} ) ;
}
}
function getInlineResults ( botID , query , offset ) {
function getInlineResults ( peerID , botID , query , offset ) {
return MtpApiManager . invokeApi ( 'messages.getInlineBotResults' , {
return MtpApiManager . invokeApi ( 'messages.getInlineBotResults' , {
flags : 0 ,
bot : AppUsersManager . getUserInput ( botID ) ,
bot : AppUsersManager . getUserInput ( botID ) ,
peer : AppPeersManager . getInputPeerByID ( peerID ) ,
query : query ,
query : query ,
offset : offset
offset : offset
} , { timeout : 1 , stopTime : - 1 , noErrorBox : true } ) . then ( function ( botResults ) {
} , { timeout : 1 , stopTime : - 1 , noErrorBox : true } ) . then ( function ( botResults ) {
@ -2461,6 +2464,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
delete botResults . flags ;
delete botResults . flags ;
delete botResults . query _id ;
delete botResults . query _id ;
if ( botResults . switch _pm ) {
botResults . switch _pm . rText = RichTextProcessor . wrapRichText ( botResults . switch _pm . text , { noLinebreaks : true , noLinks : true } ) ;
}
angular . forEach ( botResults . results , function ( result ) {
angular . forEach ( botResults . results , function ( result ) {
var qID = queryID + '_' + result . id ;
var qID = queryID + '_' + result . id ;
result . qID = qID ;
result . qID = qID ;
@ -2483,23 +2490,34 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} ) ;
} ) ;
}
}
function switchToPM ( fromPeerID , botID , startParam ) {
var setHash = { } ;
var peerString = AppPeersManager . getPeerString ( fromPeerID ) ;
setHash [ 'inline_switch_pm' + botID ] = { peer : peerString , time : tsNow ( ) } ;
Storage . set ( setHash ) ;
$rootScope . $broadcast ( 'history_focus' , { peerString : AppPeersManager . getPeerString ( botID ) } ) ;
AppMessagesManager . startBot ( botID , 0 , startParam ) ;
}
function regroupWrappedResults ( results , rowW , rowH ) {
function regroupWrappedResults ( results , rowW , rowH ) {
if ( ! results ||
if ( ! results ||
! results [ 0 ] ||
! results [ 0 ] ||
results [ 0 ] . type != 'photo' && results [ 0 ] . type != 'gif' ) {
results [ 0 ] . type != 'photo' && results [ 0 ] . type != 'gif' && results [ 0 ] . type != 'sticker' ) {
return ;
return ;
}
}
var ratios = [ ] ;
var ratios = [ ] ;
angular . forEach ( results , function ( result ) {
angular . forEach ( results , function ( result ) {
var w , h ;
var w , h , doc , photo ;
if ( result . _ == 'botInlineMediaResultDocument' ) {
if ( result . _ == 'botInlineMediaResult' ) {
w = result . document . w ;
if ( doc = result . document ) {
h = result . document . h ;
w = result . document . w ;
}
h = result . document . h ;
else if ( result . _ == 'botInlineMediaResultPhoto' ) {
}
var photoSize = ( result . photo . sizes || [ ] ) [ 0 ] ;
else if ( photo = result . photo ) {
w = photoSize && photoSize . w ;
var photoSize = ( photo . sizes || [ ] ) [ 0 ] ;
h = photoSize && photoSize . h ;
w = photoSize && photoSize . w ;
h = photoSize && photoSize . h ;
}
}
}
else {
else {
w = result . w ;
w = result . w ;