-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowOnTerminal.php
74 lines (64 loc) · 3.12 KB
/
ShowOnTerminal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace TerminalTelegram;
require_once "telegram.php";
use TelegramBot\Api\Types\Message;
use TelegramBot\Api\Types\Update;
class TerminalTelegram {
private static Message $stts;
private static string $firstName;
private static string $username;
private static string $languageCode;
private static int $fromId;
private static int $chatId;
private static string $marking;
private static string $prompt;
private static string $response;
public static function initialize(Update $update, string $marking, string $prompt, string $response){
self::$stts = $update->getMessage();
self::$firstName = self::$stts->getFrom()->getFirstName();
self::$username = self::$stts->getFrom()->getUsername();
self::$languageCode = self::$stts->getFrom()->getLanguageCode();
self::$fromId = self::$stts->getFrom()->getId();
self::$chatId = self::$stts->getChat()->getId();
self::$marking = $marking;
self::$prompt = $prompt;
self::$response = $response;
self::ShowStts();
}
private static function ShowStts(){
// if(php_uname("s") == "Linux"){
// system("clear");
// }
date_default_timezone_set('America/Bahia');
$p[] = "•––––––––––––––––––––––––––––––––––––-––-––•";
$p[] = "• TELEGRAM •";
$p[] = "•__________________________________________•";
$p[] = "| real time: |".date("Y-m-d H:i")." ";
$p[] = "|-------------------------------------------";
$p[] = "| first Name: |".self::$firstName." ";
$p[] = "|-------------------------------------------";
$p[] = "| user name: |".self::$username." ";
$p[] = "|-------------------------------------------";
$p[] = "| language Code: |".self::$languageCode." ";
$p[] = "|-------------------------------------------";
$p[] = "| from Id: |".self::$fromId." ";
$p[] = "|-------------------------------------------";
$p[] = "| chat Id: |".self::$chatId." ";
$p[] = "|-------------------------------------------";
$p[] = "| marking: |".self::$marking." ";
$p[] = "|-------------------------------------------";
$p[] = "| prompt: |".self::$prompt." ";
$p[] = "|-------------------------------------------";
$p[] = "| response: |".self::$response." ";
$p[] = "|-------------------------------------------";
foreach ($p as $key => $value) {
self::printCenteredText($value);
}
}
private static function printCenteredText($text) {
$larguraTela = shell_exec('tput cols');
$espacosAntes = (int)ceil(($larguraTela - strlen($text)) / 2);
print str_repeat(' ', $espacosAntes) . $text . PHP_EOL;
}
}
?>