mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-07 22:36:02 +00:00
fix: dingtalk adapter initializer blocks boot (#1544)
This commit is contained in:
@@ -116,15 +116,6 @@ class DingTalkAdapter(adapter.MessagePlatformAdapter):
|
|||||||
|
|
||||||
self.bot_account_id = self.config['robot_name']
|
self.bot_account_id = self.config['robot_name']
|
||||||
|
|
||||||
self.bot = DingTalkClient(
|
|
||||||
client_id=config['client_id'],
|
|
||||||
client_secret=config['client_secret'],
|
|
||||||
robot_name=config['robot_name'],
|
|
||||||
robot_code=config['robot_code'],
|
|
||||||
markdown_card=config['markdown_card'],
|
|
||||||
logger=self.logger,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def reply_message(
|
async def reply_message(
|
||||||
self,
|
self,
|
||||||
message_source: platform_events.MessageEvent,
|
message_source: platform_events.MessageEvent,
|
||||||
@@ -157,8 +148,8 @@ class DingTalkAdapter(adapter.MessagePlatformAdapter):
|
|||||||
await self.event_converter.target2yiri(event, self.config['robot_name']),
|
await self.event_converter.target2yiri(event, self.config['robot_name']),
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
await self.logger.error(f"Error in dingtalk callback: {traceback.format_exc()}")
|
await self.logger.error(f'Error in dingtalk callback: {traceback.format_exc()}')
|
||||||
|
|
||||||
if event_type == platform_events.FriendMessage:
|
if event_type == platform_events.FriendMessage:
|
||||||
self.bot.on_message('FriendMessage')(on_message)
|
self.bot.on_message('FriendMessage')(on_message)
|
||||||
@@ -166,6 +157,15 @@ class DingTalkAdapter(adapter.MessagePlatformAdapter):
|
|||||||
self.bot.on_message('GroupMessage')(on_message)
|
self.bot.on_message('GroupMessage')(on_message)
|
||||||
|
|
||||||
async def run_async(self):
|
async def run_async(self):
|
||||||
|
config = self.config
|
||||||
|
self.bot = DingTalkClient(
|
||||||
|
client_id=config['client_id'],
|
||||||
|
client_secret=config['client_secret'],
|
||||||
|
robot_name=config['robot_name'],
|
||||||
|
robot_code=config['robot_code'],
|
||||||
|
markdown_card=config['markdown_card'],
|
||||||
|
logger=self.logger,
|
||||||
|
)
|
||||||
await self.bot.start()
|
await self.bot.start()
|
||||||
|
|
||||||
async def kill(self) -> bool:
|
async def kill(self) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user