https://github.com/pknull/pk.botcore
Python bot framework with Claude SDK integration, Discord.py sessions, and command registry
https://github.com/pknull/pk.botcore
Last synced: about 1 month ago
JSON representation
Python bot framework with Claude SDK integration, Discord.py sessions, and command registry
- Host: GitHub
- URL: https://github.com/pknull/pk.botcore
- Owner: pknull
- License: mit
- Created: 2026-02-26T06:14:04.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2026-04-25T05:17:19.000Z (about 2 months ago)
- Last Synced: 2026-04-25T07:26:34.548Z (about 2 months ago)
- Language: Python
- Size: 92.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pk.botcore
Shared infrastructure for PK Discord bots (pk.zalgo and pk.asha).
## Installation
```bash
# From the bot directory (editable install)
pip install -e ../pk.botcore
# Or directly
pip install -e /home/pknull/Code/pk.botcore
```
## Modules
| Module | Purpose |
|--------|---------|
| `sessions` | User session management (persistence across messages) |
| `channels` | Channel listen mode configuration |
| `llm` | Unified LLM invocation (Claude, Codex) |
| `chunking` | Discord message chunking (2000 char limit) |
| `http` | Shared aiohttp session utilities |
| `embeds` | Discord embed helpers |
| `cmd_executor` | Dynamic command registry for [CMD:*] directives |
## Usage
```python
from pk_botcore import (
# Sessions
UserSession, load_sessions, save_sessions,
# Channels
ChannelConfig, MODE_MENTION, MODE_LISTEN, MODE_IGNORE,
load_channel_config, save_channel_config,
# LLM
LLMResponse, invoke_llm, check_relevance,
# Utilities
chunk_message, make_embed,
get_http_session, close_http_session, fetch_json,
# Commands
CommandRegistry, llm_command, CmdResult,
)
```
## Command Registry
Register cog methods for LLM to invoke via `[CMD:name:args]` directives:
```python
from pk_botcore import llm_command, CmdResult
class MyCog(commands.Cog):
@llm_command("greet")
async def cmd_greet(self, ctx, name: str) -> CmdResult:
return CmdResult(success=True, message=f"Hello, {name}!")
```
Then in your bot startup:
```python
from pk_botcore import CommandRegistry
registry = CommandRegistry(bot)
# Call after all cogs loaded
registry.discover_commands()
```
## Requirements
- Python 3.11+
- discord.py 2.0+
- aiohttp 3.8+
- claude-agent-sdk