{"id":3704,"date":"2024-03-10T10:11:00","date_gmt":"2024-03-10T02:11:00","guid":{"rendered":"https:\/\/www.bytetape.com\/?p=3704"},"modified":"2024-03-10T10:11:00","modified_gmt":"2024-03-10T02:11:00","slug":"macos%e9%80%9a%e8%bf%87%e5%bf%ab%e6%8d%b7%e6%8c%87%e4%bb%a4%e8%8e%b7%e5%8f%96%e7%9f%ad%e4%bf%a1%e9%aa%8c%e8%af%81%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.bytetape.com\/?p=3704","title":{"rendered":"macOS\u901a\u8fc7\u5feb\u6377\u6307\u4ee4\u83b7\u53d6\u77ed\u4fe1\u9a8c\u8bc1\u7801"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u7f51\u4e0a\u6709\u5f88\u591a\u7c7b\u4f3c\u7684\u6559\u7a0b\uff0c\u6211\u662f\u5728\u539f\u6765\u57fa\u7840\u4e0a\u505a\u4e86\u7b80\u5355\u7684\u8c03\u6574\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6253\u5f00\u5feb\u6377\u6307\u4ee4\uff0c\u9009\u62e9\u3010\u8fd0\u884cShell\u811a\u672c\u3011\uff0c\u590d\u5236\u4e0b\u9762\u4ee3\u7801\u4fdd\u5b58\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"706\" src=\"https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-1024x706.png\" alt=\"\" class=\"wp-image-3706\" style=\"width:581px;height:auto\" srcset=\"https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-1024x706.png 1024w, https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-300x207.png 300w, https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-768x530.png 768w, https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-1536x1060.png 1536w, https:\/\/www.bytetape.com\/wp-content\/uploads\/2024\/03\/\u622a\u5c4f2024-03-10-09.52.55-2048x1413.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\necho \"starting to check code\";\n\n# \u52a8\u6001\u83b7\u53d6\u5f53\u524d\u7528\u6237\u7684home\u76ee\u5f55\nhome_dir=$(eval echo ~$USER)\n\n# \u901a\u8fc7 Sqlite3 \u67e5 1 \u6761 iMessage \u6700\u8fd1 60 \u79d2\u6536\u5230\u5305\u542b\"\u9a8c\u8bc1\u7801\"\u7684\u6d88\u606f\nresult=$(sqlite3 $home_dir\/Library\/Messages\/chat.db 'SELECT text FROM message WHERE text LIKE \"%\u9a8c\u8bc1\u7801%\" AND datetime(date\/1000000000 + 978307200,\"unixepoch\",\"localtime\") > datetime(\"now\",\"localtime\",\"-60 second\") ORDER BY date DESC LIMIT 1;')\n\n# \u5982\u679c\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\uff0c\u5219\u53d1\u9001\u672a\u627e\u5230\u9a8c\u8bc1\u7801\u7684\u901a\u77e5\u5e76\u9000\u51fa\nif &#91; -z \"$result\" ]; then\n    echo \"latest not receive code messages\";\n    osascript -e \"display notification \\\"\u6700\u8fd160\u79d2\u672a\u6536\u5230\u9a8c\u8bc1\u7801\uff01\\\" with title \\\"\u63d0\u793a\\\"   \";\n    exit 0\nfi\n\n# \u4ece\u67e5\u8be2\u7ed3\u679c\u4e2d\u63d0\u53d6\u9a8c\u8bc1\u7801\ncode=$(echo \"$result\" | grep -o \"&#91;0-9]\\{4,6\\}\");\n\n# \u5982\u679c\u627e\u5230\u4e86\u9a8c\u8bc1\u7801\uff0c\u5c06\u5176\u590d\u5236\u5230\u526a\u8d34\u677f\u5e76\u53d1\u9001\u901a\u77e5\nif &#91; ! -z \"$code\" ]; then\n    echo \"code is $code\";\n    echo \"$code\" | pbcopy;\n    osascript -e \"display notification \\\"$code\\\" with title \\\"\u9a8c\u8bc1\u7801\u5df2\u590d\u5236\\\"\";\nelse\n    # \u5982\u679c\u6ca1\u6709\u627e\u5230\u9a8c\u8bc1\u7801\uff0c\u53d1\u9001\u672a\u627e\u5230\u9a8c\u8bc1\u7801\u7684\u901a\u77e5\n    osascript -e \"display notification \\\"\u672a\u627e\u5230\u9a8c\u8bc1\u7801\uff01\\\" with title \\\"\u63d0\u793a\\\"   \";\nfi<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7f51\u4e0a\u6709\u5f88\u591a\u7c7b\u4f3c\u7684\u6559\u7a0b\uff0c\u6211\u662f\u5728\u539f\u6765\u57fa\u7840\u4e0a\u505a&#8230; <\/p>\n","protected":false},"author":1,"featured_media":3707,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[42],"tags":[],"class_list":["post-3704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-42"],"_links":{"self":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3704"}],"version-history":[{"count":1,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3704\/revisions"}],"predecessor-version":[{"id":3708,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/posts\/3704\/revisions\/3708"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=\/wp\/v2\/media\/3707"}],"wp:attachment":[{"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bytetape.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}