memogram / framework
Make your bot with Laravel framework
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/memogram/framework
Requires
- php: ^8.2
- laravel/framework: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0@dev
This package is auto-updated.
Last update: 2025-10-25 14:35:30 UTC
README
Page & Response
class Container { public function myPage() { return "Hello World!"; } }
class SomethingElse { public function foo() { open([Container::class, 'myPage']); } }
Message response:
public function myPage() { return messageResponse("Hello world!") ->schema([ [key("Hi")->then(fn() => "Hi too!")] ]); }
Glass message response:
public function myPage() { return glassMessageResponse("Hello world!") ->schema([ [glassKey("Hi")->then(fn() => "Hi too!")] ]); }
Delete message:
public function myPage() { return deleteResponse('main'); }
Listeners:
public function myPage() { onAny(function () { return "Hello world"; }); onMessage("Bar")->then(function () { return "Baz"; }); return "Something..."; }
Validations:
Validation::make(['update', 'message', 'text', 'max:255'])->validate();
Extra
Trap Join
routes/bot.php:
onCommand('/start {inviter}', function ($inviter) { open([StartSection::class, 'start'], ['inviter' => $inviter]); });
StartSection.php:
class StartSection { public function start() { $inviter = useParam('inviter'); if (mounting()) { if ($this->joined()) { $this->giveInviteCoin($inviter); open([HomeSection::class, 'main']); return; } }; onAny(function () { return "You should join the channels first."; })->atFirst(); return messageResponse("First join the channels.") ->schema([ [key("Check")->atFirst()->then(function { if ($this->joined()) { $this->giveInviteCoin($inviter); yield "Good job!"; open([HomeSection::class, 'main']); } else { yield "You're not joined yet!"; } })], ]) } }