Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2024-03-26 (4 days ago)  | | Not enough user ratings | | Total: 17 This week: 17 | | All time: 11,219 This week: 5 |
|
Description | | Author |
This package implements a bot to delete messages in Telegram.
It implements an application that can purge messages upon a command sent to the application.
The applications must be registered as Telegram bots using a Webhook application URL. | |
 |
|
Innovation award
 Nominee: 9x
Winner: 3x |
|
Example
<?php
use Dotenv\Dotenv;
use Mateodioev\TgHandler\Bot;
use App\Commands\{Purge, Start, All};
use App\MemoryDbAdapter;
use Mateodioev\TgHandler\Log\{BulkStream, FileStream, Logger, TerminalStream};
if ($argv[0] === \basename(__FILE__)) {
fprintf(STDERR, "Do not run this file directly\n");
exit(1);
}
Dotenv::createImmutable(__DIR__)->load();
$logger = new Logger(
new BulkStream( // Log to both terminal and file
new TerminalStream(),
new FileStream(env('PWD_PATH', __DIR__) . '/info.log')
),
);
// $logger->setLevel(Logger::DEBUG, false); // Disable debug logs
$bot = new Bot(env('BOT_TOKEN'), $logger);
$bot->setDb(new MemoryDbAdapter());
$bot->setLogger($logger)
->onEvent(Purge::get())
->onEvent(Start::get())
->onEvent(new All());
return $bot;
|
Details
Purge bot
Example bot to delete messages
Installation
Clone the repository
git clone https://github.com/Mateodioev/purge-bot purge-bot-php
cd purge-bot-php
Install dependencies
composer install
Usage
Webhook mode
For this you will need a public endpoint with https
In the file webhook.php
you can find an example of a simple server with _amphp/http-server_
php webhook.php
You can also set the webhook with the file setwebhook.php
php setwebhook.php
Longpolling
For this you dont need a public server, only execute the script
php longpolling.php
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.