mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 15:56:03 +00:00
perf: ruff format & remove stream params in requester
This commit is contained in:
@@ -149,10 +149,10 @@ class DingTalkAdapter(adapter.MessagePlatformAdapter):
|
||||
quote_origin: bool = False,
|
||||
is_final: bool = False,
|
||||
):
|
||||
event = await DingTalkEventConverter.yiri2target(
|
||||
message_source,
|
||||
)
|
||||
incoming_message = event.incoming_message
|
||||
# event = await DingTalkEventConverter.yiri2target(
|
||||
# message_source,
|
||||
# )
|
||||
# incoming_message = event.incoming_message
|
||||
|
||||
# msg_id = incoming_message.message_id
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import base64
|
||||
import uuid
|
||||
import os
|
||||
import datetime
|
||||
import io
|
||||
import asyncio
|
||||
from enum import Enum
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ class OfficialAdapter(adapter_model.MessagePlatformAdapter):
|
||||
for event_handler in event_handler_mapping[event_type]:
|
||||
setattr(self.bot, event_handler, wrapper)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error in qqbotpy callback: {traceback.format_exc()}")
|
||||
self.logger.error(f'Error in qqbotpy callback: {traceback.format_exc()}')
|
||||
raise e
|
||||
|
||||
def unregister_listener(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
import telegram
|
||||
import telegram.ext
|
||||
|
||||
@@ -133,7 +133,11 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
|
||||
)
|
||||
|
||||
# notify waiter
|
||||
session = (self.webchat_group_session if isinstance(message_source, platform_events.GroupMessage) else self.webchat_person_session)
|
||||
session = (
|
||||
self.webchat_group_session
|
||||
if isinstance(message_source, platform_events.GroupMessage)
|
||||
else self.webchat_person_session
|
||||
)
|
||||
if message_source.message_chain.message_id not in session.resp_waiters:
|
||||
# session.resp_waiters[message_source.message_chain.message_id] = asyncio.Queue()
|
||||
queue = session.resp_queues[message_source.message_chain.message_id]
|
||||
@@ -147,10 +151,8 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
|
||||
# print(message_data)
|
||||
await queue.put(message_data)
|
||||
|
||||
|
||||
|
||||
return message_data.model_dump()
|
||||
|
||||
|
||||
async def is_stream_output_supported(self) -> bool:
|
||||
return self.is_stream
|
||||
|
||||
@@ -186,7 +188,10 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
|
||||
await self.logger.info('WebChat调试适配器正在停止')
|
||||
|
||||
async def send_webchat_message(
|
||||
self, pipeline_uuid: str, session_type: str, message_chain_obj: typing.List[dict],
|
||||
self,
|
||||
pipeline_uuid: str,
|
||||
session_type: str,
|
||||
message_chain_obj: typing.List[dict],
|
||||
is_stream: bool = False,
|
||||
) -> dict:
|
||||
self.is_stream = is_stream
|
||||
@@ -202,7 +207,7 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
|
||||
|
||||
if is_stream:
|
||||
use_session.resp_queues[message_id] = asyncio.Queue()
|
||||
logger.debug(f"Initialized queue for message_id: {message_id}")
|
||||
logger.debug(f'Initialized queue for message_id: {message_id}')
|
||||
|
||||
use_session.get_message_list(pipeline_uuid).append(
|
||||
WebChatMessage(
|
||||
|
||||
@@ -241,8 +241,8 @@ class WeChatPadMessageConverter(adapter.MessageConverter):
|
||||
# self.logger.info("_handler_compound_quote", ET.tostring(xml_data, encoding='unicode'))
|
||||
appmsg_data = xml_data.find('.//appmsg')
|
||||
quote_data = '' # 引用原文
|
||||
quote_id = None # 引用消息的原发送者
|
||||
tousername = None # 接收方: 所属微信的wxid
|
||||
# quote_id = None # 引用消息的原发送者
|
||||
# tousername = None # 接收方: 所属微信的wxid
|
||||
user_data = '' # 用户消息
|
||||
sender_id = xml_data.findtext('.//fromusername') # 发送方:单聊用户/群member
|
||||
|
||||
@@ -250,13 +250,10 @@ class WeChatPadMessageConverter(adapter.MessageConverter):
|
||||
if appmsg_data:
|
||||
user_data = appmsg_data.findtext('.//title') or ''
|
||||
quote_data = appmsg_data.find('.//refermsg').findtext('.//content')
|
||||
quote_id = appmsg_data.find('.//refermsg').findtext('.//chatusr')
|
||||
# quote_id = appmsg_data.find('.//refermsg').findtext('.//chatusr')
|
||||
message_list.append(platform_message.WeChatAppMsg(app_msg=ET.tostring(appmsg_data, encoding='unicode')))
|
||||
if message:
|
||||
tousername = message['to_user_name']['str']
|
||||
|
||||
_ = quote_id
|
||||
_ = tousername
|
||||
# if message:
|
||||
# tousername = message['to_user_name']['str']
|
||||
|
||||
if quote_data:
|
||||
quote_data_message_list = platform_message.MessageChain()
|
||||
|
||||
Reference in New Issue
Block a user