Skip to content

๐Ÿ›ฉ Simple & scalable PHP wrapper over MadelineProto for easy work with Telegram Client API.

Notifications You must be signed in to change notification settings

chipslays/telegram-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WIP: PHP Telegram Client

Simple & scalable PHP wrapper over MadelineProto for easy work with Telegram Client API.

๐Ÿ‘ท Work in progress...

Installation

composer require chipslays/telegram-client

Usage

Run this script in terminal like php client.php.

The first time authorization will take a long time, but the next times it will be faster.

Event system based on chipslays/event, see this for more cases.

// client.php

use Chipslays\Telegram\Client;

require_once __DIR__ . '/vendor/autoload.php';

$client = new Client([
    'session' => 'user.chipslays',
    'path' => [
        'sessions' => __DIR__ . '/storage/sessions',
    ],
    'madeline' => [
        'settings' => [
            'app_info' => [
                'app_id' => '###',
                'app_hash' => '######',
            ],
            'logger' => [
                'logger_level' => 0,
            ],
        ],
        'parse_mode' => 'html',
    ],
]);

$result = $client->sendMessage('@chipslays', 'Thank you for PHP MadelineProto wrapper! <3');

Simple userbot.

use Chipslays\Telegram\Client;
use danog\MadelineProto\Logger;

require_once __DIR__ . '/../vendor/autoload.php';

$client = new Client([
    'session' => 'user.chipslays',
    'path' => [
        'sessions' => __DIR__ . '/storage/sessions',
    ],
    'madeline' => [
        'settings' => [
            'app_info' => [
                'app_id' => '###',
                'app_hash' => '######',
            ],
            'logger' => [
                'logger_level' => 0,
            ],
        ],
        'parse_mode' => 'html',
    ],
]);

// Catch message where contains ".hello" and edit this message to "Hello World!"
// See more: https://github.com/chipslays/event
$client->on(['message.message' => '.hello'], function () use ($client) {
    if (!$client->fromMe()) {
        return;
    }

    $client->edit('Hello World!');
});

$client->on(['message.message' => '.bday {name}'], function ($name) use ($client) {
    if (!$client->fromMe()) {
        return;
    }

    $client->edit("Happy Birthday, {$name}! ๐ŸŽ‰๐ŸŽ‚");
});

// Start polling Telegram updates. 
$client->handleUpdates(function ($update) {
    // This executed on every new update.
    Logger::log($update->toArray());
});

More soon...

About

๐Ÿ›ฉ Simple & scalable PHP wrapper over MadelineProto for easy work with Telegram Client API.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages