<?php
class BroadCast extends MessageProcessor {
private $databseFriend;
function __construct($botUsername, $botToken, $webhookUrl, $sign) {
parent::__construct ( $botUsername, $botToken, $webhookUrl, $sign );
}
public function processCallback($update) {
$callBackData = $this->callback_data;
// https://telegram.me/Alnanihaa
if($callBackData=="accepted"){
$this->apiRequest ( "sendMessage", array (
'chat_id' => '@botposter',
"text" => $this->message ['text']
) );
}
}
public function processText($update) {
// incoming text message
$text = $this->message ['text'];
if (! empty ( $this->message ['reply_to_message'] ))
$repliedTomessage = $this->message ['reply_to_message'];
if (! empty ( $repliedTomessage ['text'] )) {
$reply = explode ( "@", $repliedTomessage ['text'] );
$this->apiRequestWebhook ( "sendMessage", array (
'chat_id' => $reply [0],
"text" => $text
) );
} else {
$this->apiRequest ( "sendMessage", array (
'chat_id' => $this->chat_id,
"text" => "پیام شما با موفقیت به کانال ارسال شد"
) );
}
$keyboard = [
'inline_keyboard' => [[['text' => "تایید و ارسال به کانال", 'callback_data' => "accepted"]]],
];
$markup = json_encode($keyboard, true);
$this->apiRequest ( "sendMessage", array (
'chat_id' => 44903244,
"text" => $this->message ['from'] ['id'] . "@@@" . $this->message ['from'] ['username'] . "--" . $this->message ['from'] ['first_name'] . " " . $this->message ['from'] ['last_name'] . $this->message ['text'],
'reply_markup' => $markup,
"parse_mode" => "html"
) );
}
}