Module Structure
A module in the project is a folder with Python files in the plugins directory.
The module folder is your small state. You can do whatever you want there, split your code into as many files as you need. Need additional files? Upload them! Need storage somewhere? Create your own storage! Just make sure to specify what should be passed and what should not in the .rimtubignore.
- The folder should be named in CamelCase. For example,
ExampleModule. - The module name should reflect its functionality. For example,
PythonRunner,TimeTools,Terminal. - Funny-sounding names are welcome. For example,
Carbonara(from Carbon).
.
└───plugins
├───Calculator
│ __init__.py
│ manifest.yaml
│
├───Fishh
│ __init__.py
│ manifest.yaml
│ worker.py
│
└───ExampleModule
│ __init__.py
│ manifest.yaml
│ utils.py
│ file.txt
│ .rimtubignore
│
└───dir
| ...
In the module folder, you must have the __init__.py and manifest.yaml files.
__init__.py
The main file of the module. It must include the following function:
async def main(app: Client, mod: Module):
In this function, handlers are declared.
Example __init__.py
from utils import *
async def main(app: Client, mod: Module):
cmd = mod.cmd
@cmd('hello')
async def _hello(_, msg: M):
await msg.edit("HELLO!!!")
manifest.yaml
All technical information about the module. This file contains all the details about the module: version, author, developer, dependencies, help list, etc.
module_name(str) - The module's name. It should match the folder name.version(str) - The module's version.native_RimTUB_version(str) - The original version of RimTUB for which the module was written.available_RimTUB_versions(list of str) - List of RimTUB versions on which the module works.online_check_RimTUB_versions(boolean) - Whether to check for online available versions of RimTUB that the module works on.description(str) - A description of the module.author(str) - The module's author.sections(dict) - Help list registration (see Help List).requirements(dict[str: str]) - Dependencies (see Dependencies).
Example manifest.yaml
module_name: TestM
version: 2.2-1.0.0
native_RimTUB_version: 2.2
available_RimTUB_versions:
- 2.2
- dev-2.2
online_check_RimTUB_versions: Off
description: |
Test module for module developers.
author: built-in (@RimMirK)
sections:
_:
commands:
- names: [test, t]
arguments:
- {text: required argument, req: Yes}
- {text: Optional argument, req: No }
description: Test
- {
names: [ulala, ula],
arguments: ~,
description: Ulala
}
features:
- title: Title
description: Description
testing:
description: Test part
requirements:
telebot:
check: import telebot; telebot.__version__ == '4.26.0'
install: pyTelegramBotAPI==4.26.0
.rimtubignore
The .rimtubignore file is used in the module to specify which files and directories should be ignored when sending the module (for example, with the .sm command). This is similar to the .gitignore file in Git, which excludes certain files or folders from version control.
You can learn more about such files here.
Example .rimtubignore
# Ignore all .log files
*.log
# Ignore the folder with temporary files
tmp/
# Ignore the confidential configuration file
config/secrets.json