Learner account management: - learner-add.sh: create accounts with SSH, plugin skeleton - learner-remove.sh: remove accounts with optional archive - plugin-skeleton template: starter maubot plugin Testing: - flake.nix: add checks output for pre-deploy validation - smoke-test.sh: post-deploy service verification Documentation: - learner-onboarding.md: VS Code Remote-SSH setup guide - learner-admin.md: account management procedures Skills: - code-review.md: multi-lens code review skill - orch, worklog: symlinks to shared skills
4.6 KiB
Maubot Plugin Development - Learner Onboarding
This guide walks you through setting up your development environment for building maubot plugins.
Prerequisites
- VS Code with the Remote-SSH extension
- SSH key pair - if you don't have one:
ssh-keygen -t ed25519 -C "your-email@example.com" - Your public key - send this to the admin:
cat ~/.ssh/id_ed25519.pub
Getting Connected
Once the admin has set up your account, you'll receive connection details.
1. Configure SSH
Add this to your SSH config file (~/.ssh/config on Mac/Linux, C:\Users\YOU\.ssh\config on Windows):
Host maubot-dev
HostName <server-ip>
User <your-username>
LocalForward 29316 127.0.0.1:29316
Replace <server-ip> and <your-username> with the values provided by your admin.
2. Connect with VS Code
- Open VS Code
- Press
F1(orCmd+Shift+P/Ctrl+Shift+P) - Type "Remote-SSH: Connect to Host"
- Select
maubot-dev - Wait for VS Code to connect
3. Open Your Plugin Folder
Once connected:
- Click "Open Folder"
- Navigate to
/home/<your-username>/plugins/hello_<your-username> - Click "OK"
You should see your starter plugin files.
Your First Plugin
Your starter plugin responds to two commands:
!hello- Says hello!ping- Responds with pong
Build and Deploy
-
Open the integrated terminal in VS Code (
Ctrl+``orView > Terminal) -
Build your plugin:
make buildThis creates a
.mbpfile in thedist/folder. -
Open the maubot admin UI:
- In your browser, go to: http://localhost:29316
- Log in (ask admin for credentials)
-
Upload your plugin:
- Go to "Plugins" tab
- Click "Upload new plugin"
- Select your
.mbpfile fromdist/
-
Create an instance:
- Go to "Instances" tab
- Click "Create instance"
- Select your plugin and a bot user
- Add
#learners-sandboxto allowed rooms - Click "Create"
-
Test in Matrix:
- Join the
#learners-sandboxroom - Type
!hello- your bot should respond!
- Join the
Plugin Development
File Structure
hello_yourname/
├── maubot.yaml # Plugin manifest (name, version, etc.)
├── hello_yourname/ # Python module
│ ├── __init__.py # Module init
│ └── bot.py # Your bot code
├── Makefile # Build commands
└── dist/ # Built .mbp files
Adding Commands
Edit hello_yourname/bot.py:
from maubot import Plugin, MessageEvent
from maubot.handlers import command
class Bot(Plugin):
@command.new("hello")
async def hello_command(self, evt: MessageEvent) -> None:
await evt.reply("Hello!")
# Add your new command here:
@command.new("dice")
async def dice_command(self, evt: MessageEvent) -> None:
import random
result = random.randint(1, 6)
await evt.reply(f"🎲 You rolled a {result}!")
Development Workflow
- Edit your code in VS Code
- Run
make buildin the terminal - In maubot admin, go to your instance and click "Reload"
- Test your changes in Matrix
Makefile Commands
| Command | Description |
|---|---|
make build |
Build the .mbp plugin file |
make check |
Check Python syntax |
make clean |
Remove built files |
Troubleshooting
"Connection refused" when opening localhost:29316
The SSH tunnel isn't working. Make sure:
- You're connected via VS Code Remote-SSH
- Your SSH config has the
LocalForwardline - Try disconnecting and reconnecting
Plugin doesn't appear in maubot
- Check that
make buildcompleted without errors - Make sure you uploaded the
.mbpfile from thedist/folder - Check the maubot logs for errors
Bot doesn't respond to commands
- Make sure the bot is in the room (check room members)
- Check that the room is in "allowed_rooms" in instance config
- Check maubot logs for errors
- Commands are case-sensitive:
!hellonot!Hello
Syntax errors
Run make check to validate Python syntax before building.
Need to see logs
In the maubot admin UI, go to "Logs" to see recent activity and errors.
Resources
Getting Help
- Ask in
#learners-sandbox- other learners and admins can help - Check the maubot logs for error messages
- Review the maubot documentation