122c7b630a
- Telegram: updated default bot from @MokoWaaSBot to @mokosuite_bot - Telegram: embedded obfuscated bot token in plugin PHP (XOR + base64) - Telegram: added <config> section to plugin XML for parse_mode/preview - Telegram: removed bot token from admin-visible plugin params - Branding: replaced all MokoWaaS references with MokoSuite - Wiki: reorganized into getting-started/, user-guide/, services/, developer/ - README: updated with all 36 service plugins and current features - CHANGELOG: added entries for recent fixes and changes
75 lines
2.5 KiB
Markdown
75 lines
2.5 KiB
Markdown
# Adding Custom Services
|
|
|
|
MokoSuiteCross uses a plugin-based architecture. Any developer can create a new service plugin.
|
|
|
|
## Plugin Structure
|
|
|
|
Create a Joomla plugin in the `mokosuitecross` group:
|
|
|
|
```
|
|
plg_mokosuitecross_myservice/
|
|
├── myservice.xml # Plugin manifest (group="mokosuitecross")
|
|
├── myservice.php # Legacy stub (empty)
|
|
├── src/
|
|
│ └── Extension/
|
|
│ └── MyserviceService.php # Implements MokoSuiteCrossServiceInterface
|
|
├── services/
|
|
│ └── provider.php # DI container registration
|
|
└── language/
|
|
└── en-GB/
|
|
├── plg_mokosuitecross_myservice.ini
|
|
└── plg_mokosuitecross_myservice.sys.ini
|
|
```
|
|
|
|
## Implement the Interface
|
|
|
|
Your Extension class must implement `MokoSuiteCrossServiceInterface`:
|
|
|
|
```php
|
|
namespace Joomla\Plugin\MokoSuiteCross\Myservice\Extension;
|
|
|
|
use Joomla\CMS\Plugin\CMSPlugin;
|
|
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
|
use Joomla\Event\SubscriberInterface;
|
|
|
|
class MyserviceService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
|
{
|
|
public static function getSubscribedEvents(): array
|
|
{
|
|
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
|
}
|
|
|
|
public function onMokoSuiteCrossGetServices(&$services): void
|
|
{
|
|
$services[] = $this;
|
|
}
|
|
|
|
public function getServiceType(): string { return 'myservice'; }
|
|
public function getServiceName(): string { return 'My Service'; }
|
|
public function getMaxLength(): int { return 500; }
|
|
public function supportsMedia(): bool { return true; }
|
|
|
|
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
{
|
|
// Your API integration here
|
|
return ['success' => true, 'platform_post_id' => '...', 'response' => [...]];
|
|
}
|
|
|
|
public function validateCredentials(array $credentials): array
|
|
{
|
|
return ['valid' => true, 'message' => 'OK', 'account_name' => '...'];
|
|
}
|
|
}
|
|
```
|
|
|
|
## Required Methods
|
|
|
|
| Method | Returns | Purpose |
|
|
|--------|---------|---------|
|
|
| `getServiceType()` | string | Unique identifier (lowercase, no spaces) |
|
|
| `getServiceName()` | string | Display name in admin UI |
|
|
| `publish()` | array | Send content to the platform |
|
|
| `validateCredentials()` | array | Test if credentials work |
|
|
| `getMaxLength()` | int | Character limit (0 = no limit) |
|
|
| `supportsMedia()` | bool | Whether images can be attached |
|