mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-10-31 16:07:44 +03:00 
			
		
		
		
	Implement next_offset and allow empty results in answer() (#1017)
This commit is contained in:
		
							parent
							
								
									c2966297f1
								
							
						
					
					
						commit
						2468b32fc5
					
				|  | @ -124,7 +124,7 @@ class InlineQuery(EventBuilder): | ||||||
| 
 | 
 | ||||||
|         async def answer( |         async def answer( | ||||||
|                 self, results=None, cache_time=0, *, |                 self, results=None, cache_time=0, *, | ||||||
|                 gallery=False, private=False, |                 gallery=False, next_offset=None, private=False, | ||||||
|                 switch_pm=None, switch_pm_param=''): |                 switch_pm=None, switch_pm_param=''): | ||||||
|             """ |             """ | ||||||
|             Answers the inline query with the given results. |             Answers the inline query with the given results. | ||||||
|  | @ -148,6 +148,10 @@ class InlineQuery(EventBuilder): | ||||||
|                 gallery (`bool`, optional): |                 gallery (`bool`, optional): | ||||||
|                     Whether the results should show as a gallery (grid) or not. |                     Whether the results should show as a gallery (grid) or not. | ||||||
|                  |                  | ||||||
|  |                 next_offset (`str`, optional): | ||||||
|  |                     The offset the client will send when the user scrolls the  | ||||||
|  |                     results and it repeats the request. | ||||||
|  | 
 | ||||||
|                 private (`bool`, optional): |                 private (`bool`, optional): | ||||||
|                     Whether the results should be cached by Telegram |                     Whether the results should be cached by Telegram | ||||||
|                     (not private) or by the user's client (private). |                     (not private) or by the user's client (private). | ||||||
|  | @ -163,11 +167,14 @@ class InlineQuery(EventBuilder): | ||||||
|             if self._answered: |             if self._answered: | ||||||
|                 return |                 return | ||||||
| 
 | 
 | ||||||
|  |             if results: | ||||||
|                 results = [self._as_awaitable(x, self._client.loop) |                 results = [self._as_awaitable(x, self._client.loop) | ||||||
|                            for x in results] |                            for x in results] | ||||||
| 
 | 
 | ||||||
|                 done, _ = await asyncio.wait(results, loop=self._client.loop) |                 done, _ = await asyncio.wait(results, loop=self._client.loop) | ||||||
|                 results = [x.result() for x in done] |                 results = [x.result() for x in done] | ||||||
|  |             else: | ||||||
|  |                 results = [] | ||||||
| 
 | 
 | ||||||
|             if switch_pm: |             if switch_pm: | ||||||
|                 switch_pm = types.InlineBotSwitchPM(switch_pm, switch_pm_param) |                 switch_pm = types.InlineBotSwitchPM(switch_pm, switch_pm_param) | ||||||
|  | @ -178,6 +185,7 @@ class InlineQuery(EventBuilder): | ||||||
|                     results=results, |                     results=results, | ||||||
|                     cache_time=cache_time, |                     cache_time=cache_time, | ||||||
|                     gallery=gallery, |                     gallery=gallery, | ||||||
|  |                     next_offset=next_offset, | ||||||
|                     private=private, |                     private=private, | ||||||
|                     switch_pm=switch_pm |                     switch_pm=switch_pm | ||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user