mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-11-04 00:46:43 +00:00 
			
		
		
		
	
		
			Some checks failed
		
		
	
	Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 1m25s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m24s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 1m30s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 1m23s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 1m28s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 1m33s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 1m22s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 1m37s
				
			Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 1m23s
				
			Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 1m19s
				
			Ruff Lint / Ruff Lint (push) Successful in 27s
				
			Site Deploy / publish (push) Failing after 1m31s
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.9) (push) Has been cancelled
				
			
		
			
				
	
	
	
		
			1.9 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.9 KiB
		
	
	
	
	
	
	
	
mdx, sidebar_position, description
| mdx | sidebar_position | description | ||
|---|---|---|---|---|
  | 
4 | nonebot.drivers.websockets 模块 | 
nonebot.drivers.websockets
websockets 驱动适配
nb driver install websockets
# 或者
pip install nonebot2[websockets]
:::tip 提示 本驱动仅支持客户端 WebSocket 连接 :::
def catch_closed(func)
- 
参数
func((P) -> CoroutineType[Any, Any, T])
 - 
返回
- (P) -> CoroutineType[Any, Any, T]
 
 
class Mixin(<auto>)
- 
说明: Websockets Mixin
 - 
参数
auto
 
method websocket(setup)
class WebSocket(*, request, websocket)
- 
说明: Websockets WebSocket Wrapper
 - 
参数
- 
request(Request) - 
websocket(WebSocketClientProtocol) 
 - 
 
async method accept()
- 
参数
empty
 - 
返回
- untyped
 
 
async method close(code=1000, reason="")
- 
参数
- 
code(int) - 
reason(str) 
 - 
 - 
返回
- untyped
 
 
async method receive()
- 
参数
empty
 - 
返回
- str | bytes
 
 
async method receive_text()
- 
参数
empty
 - 
返回
- str
 
 
async method receive_bytes()
- 
参数
empty
 - 
返回
- bytes
 
 
async method send_text(data)
- 
参数
data(str)
 - 
返回
- None
 
 
async method send_bytes(data)
- 
参数
data(bytes)
 - 
返回
- None