forked from piterskiy/etuts-telegram-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend-pending-post.php
44 lines (32 loc) · 1.07 KB
/
send-pending-post.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
<?php
require __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/config.php';
use Telegram\Bot\Api;
require __DIR__.'/main-controller.php';
try {
$db = new Database($db_name, $db_user, $db_pass, $chat_id, $message_id);
$telegram = new Api($token);
if (!isset($_POST['title']) ||
!isset($_POST['post_link']) ||
!isset($_POST['author_name']) ||
!isset($_POST['author_username']) ||
empty($_POST))
die;
// content of the message
$title = $_POST['title'];
$post_link = $_POST['post_link'];
$author_name = $_POST['author_name'];
$author_username = $_POST['author_username'];
$text = emoji('sand_clock') . " یک مطلب در انتظار بررسی است\n\n".
'<a href="'.$post_link.'">'.$title.'</a>' . "\n\n" .
emoji('user') . ' نویسنده ی مطلب: ' . $author_name . '(' . $author_username . ')' . "\n" .
$telegram->sendMessage([
'chat_id' => $admin_id,
'text' => $text,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true,
]);
log_debug("send-last-rss.php"); //debug
} catch (Exception $e) {
log_debug($e->getPrevious());
}