PHP code example of chipslays / telegram-client
1. Go to this page and download the library: Download chipslays/telegram-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chipslays / telegram-client example snippets
// client.php
use Chipslays\Telegram\Client;
.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');
use Chipslays\Telegram\Client;
use danog\MadelineProto\Logger;
'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());
});