| 
						
						
						
					 | 
				
				 | 
				
					@ -1,9 +1,15 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const { EOL } = require('os'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const { path } = require('../util/index.js'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const success = (response, mode) => ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						const respondAs = (mode && mode.toLowerCase() === 'html') ? 'replyWithHTML' : 'reply'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return response ? ctx[respondAs](response) : null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const parseOptions = ({ mode, asReply }, ctx) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						const respondMode = (mode && mode.toLowerCase() === 'html') ? 'replyWithHTML' : 'reply'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						const options = asReply ? { reply_to_message_id: ctx.message.message_id } : {}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return [ respondMode, options ]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const success = (response, options) => ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						const [ respondMode, replyOptions ] = parseOptions(options, ctx); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return response ? ctx[respondMode](response, replyOptions) : null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const convertCtx = ctx => { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -19,7 +25,8 @@ const convertCtx = ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						}, null, 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const fail = response => ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const fail = (response, options) => ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						const [ respondMode, replyOptions ] = parseOptions(options, ctx); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(!response | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							|| !path(['update', 'message'], ctx) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) return; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -30,7 +37,7 @@ const fail = response => ctx => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							`With context: `, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							convertCtx(ctx), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return ctx.reply(response); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return ctx[respondMode](response, replyOptions); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					module.exports = { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |