Beispiel #1
0
 public static function SendPhotoByPath(\PDO $db, $local_path, $chat_id)
 {
     $md5 = md5_file($local_path, true);
     if (isset($local_path)) {
         $photoSQL = new Photo($db);
         $file_id = $photoSQL->getServerPhotoId($md5, $local_path);
         if ($file_id !== false) {
             Telegram::fileIdPhotoSender($chat_id, $file_id);
         } else {
             $back = Telegram::customPhotoSender($chat_id, $local_path);
             $back = json_decode($back, true);
             $file_id = end($back['result']['photo'])['file_id'];
             $photoSQL->addServerPhotoId($file_id, $md5, $local_path);
         }
     }
 }
Beispiel #2
0
 public function t_wolfram()
 {
     $wolf = file_get_contents('http://www.wolframalpha.com/input/?i=' . urlencode($this->Message->text));
     preg_match_all("/http:\\/\\/www.*.wolframalpha.com\\/Calculate\\/[^<>]*\\./", $wolf, $matches, PREG_SET_ORDER);
     $img = new Imagick();
     foreach ($matches as $i) {
         $handle = fopen($i[0], 'rb');
         $img->readImageFile($handle);
     }
     $img->resetIterator();
     $combined = $img->appendImages(true);
     $date = new DateTime();
     $path = WOLFRAM_DIR . '/img' . $date->getTimestamp() . '.gif';
     $combined->writeImage($path);
     Telegram::customPhotoSender($this->Message->Chat->id, $path);
 }