mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-11-04 00:46:43 +00:00 
			
		
		
		
	Use ".handle_quick_operation" API instead of check by self
This commit is contained in:
		@@ -45,30 +45,24 @@ class RequestSession(BaseSession):
 | 
				
			|||||||
        super().__init__(bot, ctx)
 | 
					        super().__init__(bot, ctx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async def approve(self, remark: str = ''):
 | 
					    async def approve(self, remark: str = ''):
 | 
				
			||||||
        # TODO: should use ".handle_quick_operation" action in the future
 | 
					 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            if self.ctx['request_type'] == 'friend':
 | 
					            await self.bot.call_action(
 | 
				
			||||||
                await self.bot.set_friend_add_request(**self.ctx,
 | 
					                action='.handle_quick_operation_async',
 | 
				
			||||||
                                                      approve=True,
 | 
					                self_id=self.ctx.get('self_id'),
 | 
				
			||||||
                                                      remark=remark)
 | 
					                context=self.ctx,
 | 
				
			||||||
            elif self.ctx['request_type'] == 'group':
 | 
					                operation={'approve': True, 'remark': remark}
 | 
				
			||||||
                await self.bot.set_group_add_request(**self.ctx,
 | 
					            )
 | 
				
			||||||
                                                     type=self.ctx['sub_type'],
 | 
					 | 
				
			||||||
                                                     approve=True)
 | 
					 | 
				
			||||||
        except CQHttpError:
 | 
					        except CQHttpError:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async def reject(self, reason: str = ''):
 | 
					    async def reject(self, reason: str = ''):
 | 
				
			||||||
        # TODO: should use ".handle_quick_operation" action in the future
 | 
					 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            if self.ctx['request_type'] == 'friend':
 | 
					            await self.bot.call_action(
 | 
				
			||||||
                await self.bot.set_friend_add_request(**self.ctx,
 | 
					                action='.handle_quick_operation_async',
 | 
				
			||||||
                                                      approve=False)
 | 
					                self_id=self.ctx.get('self_id'),
 | 
				
			||||||
            elif self.ctx['request_type'] == 'group':
 | 
					                context=self.ctx,
 | 
				
			||||||
                await self.bot.set_group_add_request(**self.ctx,
 | 
					                operation={'approve': False, 'reason': reason}
 | 
				
			||||||
                                                     type=self.ctx['sub_type'],
 | 
					            )
 | 
				
			||||||
                                                     approve=False,
 | 
					 | 
				
			||||||
                                                     reason=reason)
 | 
					 | 
				
			||||||
        except CQHttpError:
 | 
					        except CQHttpError:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user