PHP Classes

File: test/myChatWith.php

Recommend this page to a friend!
  Classes of Joseluis Laso   PHP Telegram CLI Wrapper   test/myChatWith.php   Download  
File: test/myChatWith.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Telegram CLI Wrapper
Send messages and other commands to Telegram users
Author: By
Last change:
Date: 8 years ago
Size: 692 bytes
 

Contents

Class file image Download
<?php

if (!isset($argv[1])) {
    die(
"You have to call this program with the peer you want to see current messages\n");
}

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

use
TelegramCliWrapper\TelegramCliWrapper;
use
TelegramCliWrapper\TelegramCliHelper;
use
TelegramCliWrapper\Models\Dialog;

$th = TelegramCliHelper::getInstance();
$t = new TelegramCliWrapper($th->getSocket(), $th->isDebug());

$peer = trim($argv[1]);
$n = isset($argv[2]) ? intval($argv[2]) : 5;

print
"The last $n messages with '$peer' are " . PHP_EOL .
   
Dialog::getTitles() . PHP_EOL;

$history = $t->getHistory($peer, $n);
foreach (
$history as $historyItem) {
    print
$historyItem . PHP_EOL;
}

$t->quit();