memogram/framework

There is no license information available for the latest version (dev-main) of this package.

Make your bot with Laravel framework

Installs: 30

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/memogram/framework

dev-main 2025-10-26 15:54 UTC

This package is auto-updated.

Last update: 2025-10-26 15:54:42 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!";
                    }
                })],
            ])
    }
}