80 lines
2.7 KiB
Markdown
80 lines
2.7 KiB
Markdown
# Ad Support & Multi-line Comment Fix
|
|
|
|
## Changes in this branch
|
|
|
|
### 1. Fixed `\n` handling in replies and ads
|
|
The bot now properly converts literal `\n` escape sequences to actual newlines when loading replies from `storage/replies.txt` and ads from `storage/ads.txt`. This fixes the issue where the Lolz API couldn't handle multi-line comments properly.
|
|
|
|
**Before**: `\n` was sent as literal text
|
|
**After**: `\n` is converted to actual newline characters
|
|
|
|
### 2. Added Ad Support
|
|
You can now add advertisements to your bot's comments with configurable probability.
|
|
|
|
#### Configuration (`.env`):
|
|
```env
|
|
# Enable/disable ads (default: false)
|
|
ENABLE_ADS=true
|
|
|
|
# Probability of adding an ad to a comment (0.0 - 1.0, where 1.0 = 100%)
|
|
# Default: 0.3 (30% chance)
|
|
ADS_PROBABILITY=0.3
|
|
```
|
|
|
|
#### Ad File (`storage/ads.txt`):
|
|
Create a file `storage/ads.txt` with your ad content. The file can contain multi-line BBCode:
|
|
|
|
```
|
|
[ad=align=center][CENTER]PROXYLEET — прокси под работу с аккаунтами и трафиком.
|
|
Серверные IPv4 (десятки стран), мобильные, MTProto. От 164 ₽ / 30 дней.
|
|
Выдача автоматическая, оплата с баланса лолза.
|
|
Промокод LOLZ10 — 10% скидки.
|
|
|
|
[UNFURL]https://lolz.team/threads/1337[/UNFURL][/CENTER][/ad]
|
|
```
|
|
|
|
**Note**: You can use `\n` in the ad file to create newlines, and it will be converted to actual newlines automatically.
|
|
|
|
### 3. How it works
|
|
- When `ENABLE_ADS=true`, the bot will randomly add the ad content to comments based on `ADS_PROBABILITY`
|
|
- The ad is appended to the comment with a double newline separator (`\n\n`)
|
|
- Each comment has an independent chance of including the ad
|
|
- If the ad file is not found or empty, ads are silently skipped
|
|
|
|
### Example Usage
|
|
|
|
**Without ads**:
|
|
```
|
|
✓
|
|
```
|
|
|
|
**With ads (30% probability)**:
|
|
```
|
|
✓
|
|
|
|
[ad=align=center][CENTER]PROXYLEET — прокси под работу с аккаунтами и трафиком.
|
|
Серверные IPv4 (десятки стран), мобильные, MTProto. От 164 ₽ / 30 дней.
|
|
Выдача автоматическая, оплата с баланса лолза.
|
|
Промокод LOLZ10 — 10% скидки.
|
|
|
|
[UNFURL]https://lolz.team/threads/1337[/UNFURL][/CENTER][/ad]
|
|
```
|
|
|
|
### Migration from main branch
|
|
1. Update your `.env` file with the new variables (see `.env.example`)
|
|
2. Create `storage/ads.txt` with your ad content (optional)
|
|
3. Existing `storage/replies.txt` will now properly handle `\n` sequences
|
|
|
|
### Testing
|
|
To test the multi-line functionality, you can use `\n` in your replies:
|
|
```
|
|
First line\nSecond line\nThird line
|
|
```
|
|
|
|
This will now correctly appear as:
|
|
```
|
|
First line
|
|
Second line
|
|
Third line
|
|
```
|