Monday, October 31, 2016

Function Send Message Bot Telegram With Split 4096 Character

Script standar Telegram ini saya modif digunakan untuk memotong 4096 karakter dan mengirim secara continue, scriptnya :

function sendMessage(array $data){
  $max_length = 4096;
  $text = $data['text'];
  $string_len = strlen($text);
  if ($string_len > $max_length) {
	if ($text{$max_length - 1} != ' ') {
		$data['text'] = substr($text, 0, $max_length);
		$new_pos = strrpos($data['text'], ' ');
		$data['text'] = substr($text, 0, $new_pos) . ' ...';
		apiRequest("sendMessage", $data);
	}
	$data['text'] = substr($text, $new_pos, $string_len);
	return apiRequest("sendMessage", $data);
  }
  return apiRequest("sendMessage", $data);
}
Sekian dan terima kasih.
Function Send Message Bot Telegram With Split 4096 Char

Post a Comment