diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-02-05 00:10:23 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-02-05 00:13:21 +0300 |
commit | 1f919eaef022b4721ecb9f72a0ea703b2ac3e89a (patch) | |
tree | 53f75ef906c296b9da4598e128f677b4b926194b /get-attaches.php |
Diffstat (limited to 'get-attaches.php')
-rw-r--r-- | get-attaches.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/get-attaches.php b/get-attaches.php new file mode 100644 index 0000000..36c12ee --- /dev/null +++ b/get-attaches.php @@ -0,0 +1,31 @@ +<?php + +require_once __DIR__.'/common.php'; + +$str = file_get_contents('php://stdin'); +if (!$str) + fatalError("no input"); + +$message_ids = []; +$photo_urls = []; + +$on_message = function($doc, $message_id) { + global $message_ids; + $message_ids[] = $message_id; +}; +$on_photo = function($doc, $href, $link_node) { + global $photo_urls; + $photo_urls[] = $href; +}; + +try { + onEachMessageOrAttachment($str, $on_message, $on_photo); +} catch (Exception $e) { + fatalError($e->getMessage()); +} + +if (!empty($message_ids)) + echo implode("\n", $message_ids)."\n"; + +if (!empty($photo_urls)) + echo implode("\n", $photo_urls)."\n";
\ No newline at end of file |