feat: Added docs via MkDocs

This commit is contained in:
AURUMVORXX
2024-11-04 05:09:59 +03:00
parent 810dd00dd8
commit 6a20d96bb5
21 changed files with 299 additions and 63 deletions

View File

@@ -0,0 +1,27 @@
# `event` onBan
!!! note
If serial/mac/ip/name indexes doesn't exist, then the parameters has not been specified when ban was added.
If timestamp doesn't exist, then ban was permanent.
This event is triggered when new ban is being added.
## Parameters
* `dict` **kwargs**:
* `str` **mac**: MAC address of the banned player.
* `str` **ip**: IP address of the banned player.
* `str` **serial**: serial of the banned player.
* `str` **name**: nickname of the banned player.
* `int` **timestamp**: timestamp when the ban expires.
## Usage
```python
import g2o
from datetime import datetime
@g2o.event('onBan')
def onBan(**kwargs):
print(f'Player {kwargs['name']} has been banned.')
if ('timestamp' in kwargs):
banExpires = datetime.fromtimestamp(kwargs['timestamp'])
print(f'Ban expires at {banExpires}')
```

View File

@@ -0,0 +1,15 @@
# `event` onExit
This event is triggered when server is going to shut down.
You can use it, to save some data before closing up, or do something else.
## Parameters
No parameters.
## Usage
```python
import g2o
@g2o.event('onExit')
def onExitEvt(**kwargs):
print('Bye')
```

View File

@@ -0,0 +1,14 @@
# `event` onInit
This event is triggered when server successfully starts up.
## Parameters
No parameters.
## Usage
```python
import g2o
@g2o.event('onInit')
def onInitEventHandler(**kwargs):
print('Called onInit event')
```

View File

@@ -0,0 +1,14 @@
# `event` onTick
This event is triggered in every server main loop iteration.
## Parameters
No parameters.
## Usage
```python
import g2o
@g2o.event('onTick')
def onTickEvt(**kwargs):
print('Tock')
```

View File

@@ -0,0 +1,20 @@
# `event` onTime
This event is triggered each time when game time minute passes.
## Parameters
* `dict` **kwargs**:
* `int` **day**: the current ingame day.
* `int` **hour**: the current ingame hour.
* `int` **min**: the current ingame minutes.
## Usage
```python
import g2o
@g2o.event('onTick')
def onTickEvt(**kwargs):
day = kwargs['day']
hour = kwargs['hour']
mins = kwargs['min']
print(f'Current time: Day {day}, Hour {hour}, Min {mins}')
```

View File

@@ -0,0 +1,23 @@
# `event` onUnban
!!! note
If serial/mac/ip/name indexes doesn't exist, then the parameters has not been specified when ban was added.
If timestamp doesn't exist, then ban was permanent.
This event is triggered when ban with specified info is being removed.
## Parameters
* `dict` **kwargs**:
* `str` **mac**: MAC address of the banned player.
* `str` **ip**: IP address of the banned player.
* `str` **serial**: serial of the banned player.
* `str` **name**: nickname of the banned player.
* `int` **timestamp**: timestamp when the ban expires.
## Usage
```python
import g2o
@g2o.event('onUnban')
def onUnban(**kwargs):
print(f'Player {kwargs['name']} has been unbanned.')
```