新增 IRC 渠道的完整扩展实现,包括客户端连接管理、消息收发与流式处理、安全策略与配对验证、消息去重与规范化、状态监控与健康探测、配置模型与账户管理、错误处理等模块。
36 lines
716 B
Python
36 lines
716 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class IrcStreamBuffer:
|
|
|
|
def __init__(self):
|
|
self._chunks: list[str] = []
|
|
self._finished = False
|
|
|
|
def feed(self, chunk: str) -> None:
|
|
self._chunks.append(chunk)
|
|
|
|
def flush(self) -> str:
|
|
content = "".join(self._chunks)
|
|
self._chunks.clear()
|
|
return content
|
|
|
|
@property
|
|
def content(self) -> str:
|
|
return "".join(self._chunks)
|
|
|
|
@property
|
|
def is_empty(self) -> bool:
|
|
return len(self._chunks) == 0
|
|
|
|
def mark_finished(self) -> None:
|
|
self._finished = True
|
|
|
|
@property
|
|
def finished(self) -> bool:
|
|
return self._finished
|