mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2026-04-23 00:30:26 +00:00
Add Russian
This commit is contained in:
36
docs/ru/plugins/example.py
Normal file
36
docs/ru/plugins/example.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import BEAMP # Import server object
|
||||
|
||||
beam = BEAMP("TestPlugin") # Init plugin with name "TestPlugin"
|
||||
log = beam.log # Use logger from server
|
||||
|
||||
|
||||
def on_load():
|
||||
# When plugin initialization Server uses plugin.load() to load plugin.
|
||||
# def load(): is really needed
|
||||
log.info(beam.name)
|
||||
|
||||
|
||||
# Events handlers
|
||||
|
||||
def on_started():
|
||||
# Simple event handler
|
||||
log.info("Server starting...")
|
||||
|
||||
|
||||
# Simple event register
|
||||
beam.register_event("on_started", on_started)
|
||||
|
||||
|
||||
def any_func(data=None):
|
||||
# Custom event handler
|
||||
log.info(f"Data from any_func: {data}")
|
||||
|
||||
|
||||
# Create custom event
|
||||
beam.register_event("my_event", any_func)
|
||||
|
||||
# Call custom event
|
||||
beam.call_event("my_event")
|
||||
beam.call_event("my_event", "Some data")
|
||||
# This will be an error since any_func accepts only one argument at the input
|
||||
beam.call_event("my_event", "Some data", "Some data1")
|
||||
35
docs/ru/plugins/readme.md
Normal file
35
docs/ru/plugins/readme.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Система плагинов
|
||||
|
||||
## Установка библиотеки с "Заглушками"
|
||||
###### (Это значит, что не будет работать без сервера, но IDE подскажет API)
|
||||
###### (Библиотека ещё в разработке)
|
||||
|
||||
* Используя pip:\
|
||||
`$ pip install ...`
|
||||
* Из исходников:\
|
||||
`git clone https://github.com/kuitoi/...`
|
||||
|
||||
## Пример
|
||||
|
||||
```python
|
||||
import BEAMP
|
||||
|
||||
beam = BEAMP("TestPlugin")
|
||||
logger = beam.log
|
||||
|
||||
def load(): # Plugins load from here
|
||||
print(beam.name)
|
||||
|
||||
def on_started():
|
||||
logger.info("Server starting...")
|
||||
|
||||
beam.register_event("on_started", on_started)
|
||||
```
|
||||
|
||||
Так же более обширный пример можно найти в [example.py](./example.py)
|
||||
|
||||
* Базовые ивенты: ['on_started', 'on_auth, 'on_stop']
|
||||
* Создание своего ивента : `beam.register_event("my_event", my_event_function)`
|
||||
* Вызов ивента: `beam.call_event("my_event")`
|
||||
* Вызов ивента с данными: `beam.call_event("my_event", data, data2)`
|
||||
* Вызовы с указанием переменой _**не поддерживаются**_: `beam.call_event("my_event", data=data)`
|
||||
Reference in New Issue
Block a user