Skip to content

Instantly share code, notes, and snippets.

@kenniki
Created July 8, 2015 20:25
Show Gist options
  • Select an option

  • Save kenniki/567de2a08fac10a43975 to your computer and use it in GitHub Desktop.

Select an option

Save kenniki/567de2a08fac10a43975 to your computer and use it in GitHub Desktop.
<?php
class connector {
private $process;
private $pipes;
private $core;
public function __construct($core) {
$this->core = $core;
$cmd = "/opt/tg-bin/telegram-cli --json -k /opt/tg-bin/server.pub --disable-link-preview -I -R -C -N";
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
flush();
$this->process = proc_open($cmd, $descriptorspec, $this->pipes, realpath('./'), array());
fwrite($this->pipes[0], 'status_online' . PHP_EOL);
flush();
}
public function replyTxt($msg, $rcpt) {
fwrite($this->pipes[0], 'msg '.$rcpt.' "' . $msg . '"' . PHP_EOL);
flush();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment