forked from piterskiy/etuts-telegram-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend-post.php
executable file
·37 lines (29 loc) · 1.04 KB
/
send-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
<?php
require __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/config.php';
use Telegram\Bot\Api;
require __DIR__.'/main-controller.php';
try {
$telegram = new Api($token);
if (empty($_POST) || !isset($_POST['title']) || !isset($_POST['content']) || !isset($_POST['bot_id']) || !isset($_POST['image_link']))
die;
// content of the message
$title = $_POST['title'];
$content = $_POST['content'];
$content = html_entity_decode(strip_tags($content));
$image_link = $_POST['image_link'];
$bot_id = $_POST['bot_id'];
$text = $title . "\n\n" . emoji('id') . ' @' . $bot_id . "\n\n" . $content;
if ($image_link != false) {
$text = '<a href="'.$image_link.'"> </a>' . $text;
}
$text .= "\n" . "\n" . "@etuts #bot";
// log_debug("مطلبی که رفته بود تو کانال دوباره داشت میفرت تو کانال " . $_POST['debug'] . ' ' . $text . ' ' . $channel_id);
$telegram->sendMessage([
'chat_id' => $channel_id,
'text' => $text,
'parse_mode' => 'HTML',
]);
} catch (Exception $e) {
log_debug($e->getPrevious());
}