# nonebot/nonebot2

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/nonebot-nonebot2).**

7,582 stars · 663 forks · Python · MIT

## Links

- GitHub: https://github.com/nonebot/nonebot2
- Homepage: https://nonebot.dev
- awesome-repositories: https://awesome-repositories.com/repository/nonebot-nonebot2.md

## Topics

`bot` `chatbot` `cqhttp` `dingtalk-robot` `fastapi` `lark-bot` `mirai-bot` `nonebot` `nonebot2` `onebot` `python` `qq` `qq-guild` `telegram-bot`

## Description

Nonebot2 is an asynchronous Python framework for building event-driven chatbots across multiple messaging platforms. It centers on a non-blocking event bus and a driver-based adapter system that unifies different messaging protocols into a single consistent interface.

The framework utilizes a modular plugin architecture, allowing for the discovery and loading of third-party extensions to add new event handlers and system capabilities. It distinguishes itself with a type-annotation based dependency injection system that automatically resolves and provides required service objects to handlers at runtime.

The system includes a rule-based routing engine to filter events and a session-aware context model to maintain state across multi-turn interactions. Performance is managed by offloading blocking synchronous functions to a separate thread pool to prevent stalling the main asynchronous loop.

Project initialization is supported through automated scaffolding tools that generate standardized directory structures and IDE configurations.

## Tags

### Artificial Intelligence & ML

- [Multi-Platform Chatbot Development](https://awesome-repositories.com/f/artificial-intelligence-ml/multi-platform-chatbot-development.md) — Provides a framework for building chatbot backends that operate across multiple messaging platforms from a single codebase. ([source](https://cdn.jsdelivr.net/gh/nonebot/nonebot2@master/README.md))
- [Chatbot Frameworks](https://awesome-repositories.com/f/artificial-intelligence-ml/chatbot-frameworks.md) — Provides an asynchronous Python framework for building event-driven chatbots across multiple messaging platforms.
- [Conversation State Management](https://awesome-repositories.com/f/artificial-intelligence-ml/context-aware-retrieval/context-aware-conversation-managers/conversation-state-management.md) — Tracks conversation context and per-user state to facilitate seamless multi-turn dialogue interactions.
- [Session Context Retention](https://awesome-repositories.com/f/artificial-intelligence-ml/conversational-ai/session-context-retention.md) — Maintains per-conversation state and context across multiple events to enable complex multi-turn interactions.
- [Thread-Pooled](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-deployment-and-serving/local-and-on-device-inference/local-model-inference-servers/remote-inference-offloaders/task-offloaders/thread-pooled.md) — Offloads blocking synchronous functions to a separate worker thread pool to prevent freezing the main async loop.

### Development Tools & Productivity

- [Plugin Package Loading](https://awesome-repositories.com/f/development-tools-productivity/cli-command-extensions/plugin-package-loading.md) — Enables the discovery and importing of third-party Python packages as modular extensions to add new capabilities.

### Networking & Communication

- [Protocol Abstraction Layers](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/messaging-notification-systems/messaging-protocols/protocol-abstraction-layers.md) — Standardizes diverse messaging protocols into a consistent internal event format using an abstraction layer.
- [Asyncio Frameworks](https://awesome-repositories.com/f/networking-communication/message-brokers/asyncio-frameworks.md) — Built around the Python asyncio event loop to execute multiple event handlers concurrently without stalling.
- [Protocol Action Adapters](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/messaging-notification-systems/messaging-protocols/protocol-abstraction-layers/data-store-protocol-adapters/protocol-action-adapters.md) — Separates platform-specific communication logic into interchangeable adapters that map to internal protocol actions.
- [Event Routing Matchers](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-routing-traffic-management/request-routing/expression-based-matchers/event-routing-matchers.md) — Filters events through a chain of rule-based matchers to determine the appropriate handler for each message.

### Software Engineering & Architecture

- [Chat Platform Adapters](https://awesome-repositories.com/f/software-engineering-architecture/adapter-patterns/chat-platform-adapters.md) — Provides a driver-based adapter system that unifies different messaging protocols into a single consistent interface.
- [Dependency Injection Containers](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-containers.md) — Features a runtime system that automatically resolves and injects required objects into handlers to promote loose coupling.
- [Event Bus Architectures](https://awesome-repositories.com/f/software-engineering-architecture/event-bus-architectures.md) — Features a non-blocking event pipeline that dispatches messages and system events using Python asyncio.
- [Dependency Injection](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/dependency-injection.md) — Implements a type-annotation based dependency injection system to automatically provide service objects to event handlers.
- [Type-Hint Injection Systems](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/dependency-injection/annotation-based-injection-systems/type-hint-injection-systems.md) — Resolves and injects required service objects into handler functions at runtime based on Python type hints.
- [Event Handler Injection](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/dependency-injection/event-handler-injection.md) — Automatically injects required service objects into asynchronous event handlers to eliminate manual wiring boilerplate. ([source](https://nonebot.dev/))
- [Chat Interface Adapters](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures/developer-authoring-interfaces/custom-module-implementations/chat-interface-adapters.md) — Implements a unified interface and adapters to manage events and responses across various messaging platforms. ([source](https://nonebot.dev/))
- [Third-Party Plugins](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/third-party-plugins.md) — Extends system functionality by installing and activating community or custom extension packages. ([source](https://nonebot.dev/))
- [Non-Blocking Event Loops](https://awesome-repositories.com/f/software-engineering-architecture/non-blocking-event-loops.md) — Uses a non-blocking event loop to dispatch messages through a central pipeline for concurrent handler execution.
- [Plugin-Based Architectures](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures.md) — Utilizes a modular plugin architecture for the discovery and loading of third-party extensions to add new handlers.
- [Plugin-Based Architectures](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures/plugin-based-architectures.md) — Implements a modular architecture that discovers and loads external Python packages as plugins with a standardized interface.
- [Modular Extension Architectures](https://awesome-repositories.com/f/software-engineering-architecture/modular-extension-architectures.md) — Allows adding or removing specific feature sets through a modular architecture to manage capabilities independently. ([source](https://nonebot.dev/docs/))

### DevOps & Infrastructure

- [Event Filtering Rules](https://awesome-repositories.com/f/devops-infrastructure/event-filtering-rules.md) — Evaluates event-matching rules through a chain of filters to route messages to the correct handlers.

### Programming Languages & Runtimes

- [Asynchronous Processing](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/asynchronous-processing.md) — Processes multiple concurrent interactions using non-blocking execution to maintain high system responsiveness. ([source](https://nonebot.dev/docs/))
