Created
July 8, 2015 20:25
-
-
Save kenniki/567de2a08fac10a43975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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