LXMFy
Easily create LXMF bots for the Reticulum Network with this framework.
pip install lxmfy
lxmfy create mybot
Features
First Message Handler
Custom welcome messages for new users
Storage Options
SQLite or JSON storage
Permission System
Role-based access control with hierarchical permissions
Hot Reloading
Cog system for modular bot development
Moderation
Built-in commands for user management
Help System
Automatic command documentation and help
Spam Protection
Rate limiting and protection
Transport Layer
Path discovery and caching
Projects Using LXMFy
Python Example
from lxmfy import LXMFBot
bot = LXMFBot(
name="BasicBot",
announce=600,
command_prefix="/",
first_message_enabled=True,
storage_type="sqlite",
storage_path="bot.db"
)
@bot.on_first_message()
def welcome(sender, message):
bot.send(sender, "Welcome! Type /help to see commands.")
return True
@bot.command(name="ping", description="Test if bot is responsive")
def ping(ctx):
ctx.reply("Pong!")
@bot.command(name="echo", description="Echo back your message")
def echo(ctx):
if ctx.args:
ctx.reply(" ".join(ctx.args))
else:
ctx.reply("Please provide a message to echo")
if __name__ == "__main__":
bot.run()
Framework Development
Core Architecture
Core Module
Core bot functionality, message routing, permissions and command handling.
class LXMFBot:
def __init__(self, **kwargs):
self.transport = Transport()
self.storage = Storage()
self.permissions = PermissionManager()
self.help_system = HelpSystem()
def command(self, name, **kwargs):
def decorator(func):
cmd = Command(name=name, **kwargs)
self.commands[name] = cmd
return func
return decorator
Key Components
RNS/LXMF Integration
- Network handlingPermission System
- Role-based access controlHelp System
- Command documentationSpam Protection
- Rate limiting and moderationStorage System
- Persistent data handlingExtension System
- Hot-reloadable modules
Permission System
Role-based access control with hierarchical permissions.
class DefaultPerms(Flag):
USE_BOT = auto()
SEND_MESSAGES = auto()
USE_COMMANDS = auto()
MANAGE_USERS = auto()
ALL = USE_BOT | SEND_MESSAGES | USE_COMMANDS | MANAGE_USERS
@dataclass
class Role:
name: str
permissions: DefaultPerms
priority: int = 0
class PermissionManager:
def create_role(self, name, permissions):
pass
def assign_role(self, user, role):
pass
def has_permission(self, user, perm):
pass
Features
Role System
- Hierarchical rolesPermission Flags
- Granular permissionsPriority System
- Role precedencePersistence
- Stored role assignments
Help System
Dynamic command documentation and help formatting.
@dataclass
class CommandHelp:
name: str
description: str
usage: Optional[str]
examples: List[str]
category: str
class HelpFormatter:
def format_command(self, command):
pass
def format_category(self, category):
pass
@bot.command(
name="help",
description="Show command help",
usage="help [command]"
)
Features
Command Help
- Usage documentationCategories
- Command groupingExamples
- Usage examplesPermissions
- Required permissions displayCustom Formatting
- Flexible output