Spade
Mini Shell
| Directory:~$ /proc/self/root/home/lmsyaran/public_html/joomla3/plugins/chat/send_by_bale/classes/ |
| [Home] [System Details] [Kill Me] |
<?php
class send{
public static $bot_token;
public static $getupdates_url;
public static $sendmessage_url;
public static $editmessage_url;
public static $deletemessage_url;
public function __construct($bot_token)
{
}
public static function send_bale_message($data=[], $type=
'send')
{
$params= json_decode(jpluginhelper::getPlugin('chat',
'send_by_bale')->params);
self::$bot_token= $params->bot_token;
self::$getupdates_url=
"https://tapi.bale.ai/bot".self::$bot_token."/getupdates";
self::$sendmessage_url=
"https://tapi.bale.ai/bot".self::$bot_token."/sendMessage";
self::$editmessage_url=
"https://tapi.bale.ai/bot".self::$bot_token."/editMessageText";
self::$deletemessage_url=
"https://tapi.bale.ai/bot".self::$bot_token."/deletemessage";
$curl = curl_init();
if ($type== 'send')
curl_setopt($curl, CURLOPT_URL, self::$sendmessage_url);
elseif ($type== 'edit')
curl_setopt($curl, CURLOPT_URL, self::$editmessage_url);
else if ($type== 'delete')
curl_setopt($curl, CURLOPT_URL, self::$deletemessage_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Content-Type:
application/json'));
curl_setopt($curl, CURLOPT_POST, 1);
// curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 2000);
// curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1000);
$responses = [];
foreach ($data as $item)
{
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($item));
$response = curl_exec($curl);
$responses[$item['chat_id']][] = json_decode($response);
}
// $err = curl_error($curl);
curl_close($curl);
return $responses;
}
}