{"id":1774,"date":"2021-07-09T14:26:51","date_gmt":"2021-07-09T06:26:51","guid":{"rendered":"https:\/\/maofun.com\/?p=1774"},"modified":"2021-07-09T14:26:51","modified_gmt":"2021-07-09T06:26:51","slug":"tg%e8%87%aa%e5%8a%a8%e7%ad%be%e5%88%b0%e8%84%9a%e6%9c%ac%ef%bc%8c%e6%94%af%e6%8c%81%e5%a4%9a%e8%b4%a6%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/maofun.com\/1774.html","title":{"rendered":"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7"},"content":{"rendered":"<p><strong>\u4e00\u3001\u7b80\u4ecb<\/strong>\nTG\u4e0a\u7684\u67d0\u4e9b\u673a\u5668\u4eba\u7ecf\u5e38\u4f1a\u6709\u6bcf\u65e5\u7b7e\u5230\u62ff\u79ef\u5206\u7684\u6d3b\u52a8\uff0c\u867d\u8bf4\u6bcf\u5929\u4e0a\u53f7\u70b9\u4e00\u70b9\u4e5f\u4e0d\u9ebb\u70e6\uff0c\u4f46\u65f6\u95f4\u4e45\u4e86\u5c31\u7ecf\u5e38\u4f1a\u5fd8\u8bb0\u3002\u672c\u6559\u7a0b\u5c06\u5206\u4eab\u4e00\u79cd\u6bd4\u8f83\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u57fa\u4e8eTG API\u4ee5\u53caPython\u7684\u7b2c\u4e09\u65b9\u5305Telethon\uff0c\u90e8\u7f72\u5230VPS\u4e0a\uff0c\u6bcf\u5929\u5b9a\u65f6\u4e0aTG\u81ea\u52a8\u7b7e\u5230<\/p>\n<p><strong>\u4e8c\u3001\u51c6\u5907\u5de5\u4f5c<\/strong>\n1\u3001\u5df2\u5f00\u542fAPI\u7684TG\u53f7\uff08\u4e0b\u9762\u4f1a\u8bb2\u8ff0\u5982\u4f55\u5f00\u542fTG API\uff09\n2\u3001\u56fd\u5916VPS\u4e00\u53f0\uff08\u6216\u80fd\u9b54\u6cd5\u4e0a\u7f51\u7684\u8f6f\u8def\u7531\uff09\n3\u3001Python 3.5+<\/p>\n<p><strong>\u4e09\u3001\u5f00\u542fTG API<\/strong>\n\u7533\u8bf7\u7f51\u5740\uff1ahttps:\/\/my.telegram.org\n1\u3001\u8f93\u5165\u624b\u673a\u53f7\u767b\u5f55\uff0c\u6ce8\u610f\u9a8c\u8bc1\u7801\u4f1a\u53d1\u9001\u81f3TG\u5ba2\u6237\u7aef\u800c\u4e0d\u4f1a\u4ee5\u77ed\u4fe1\u5f62\u5f0f\u53d1\u9001\n2\u3001\u767b\u5f55\u8fdb\u53bb\u540e\u9009\u201cAPI development tools\u201d\n<img loading=\"lazy\" decoding=\"async\" id=\"aimg_IDVnZ\" class=\"zoom\" src=\"https:\/\/maofun.com\/wp-content\/uploads\/2021\/07\/3549d-W75SVmCIl4cNOMd.png\" width=\"600\" height=\"186\" border=\"0\" \/ alt=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c1\u5f20\u56fe\u7247\" title=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c1\u5f20\u56fe\u7247 | \u732b\u996d\" >\n3\u3001\u6839\u636e\u4e0b\u56fe\u63d0\u793a\u8f93\u5165\u7533\u8bf7\u4fe1\u606f\n<img loading=\"lazy\" decoding=\"async\" id=\"aimg_x6koY\" class=\"zoom\" src=\"https:\/\/maofun.com\/wp-content\/uploads\/2021\/07\/660de-LbZ2JPwotr84lzg.png\" width=\"600\" height=\"330\" border=\"0\" \/ alt=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c2\u5f20\u56fe\u7247\" title=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c2\u5f20\u56fe\u7247 | \u732b\u996d\" >\n4\u3001\u5f00\u901a\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58api_id\u3001api_hash\u4e24\u4e2a\u503c\n<img loading=\"lazy\" decoding=\"async\" id=\"aimg_uoo4c\" class=\"zoom\" src=\"https:\/\/maofun.com\/wp-content\/uploads\/2021\/07\/f23de-eGr7tYl1JPSMzAD.png\" width=\"600\" height=\"196\" border=\"0\" \/ alt=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c3\u5f20\u56fe\u7247\" title=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c3\u5f20\u56fe\u7247 | \u732b\u996d\" ><\/p>\n<p><strong>\u56db\u3001\u5b89\u88c5Python\u4e0eTelethon<\/strong>\n1\u3001\u5b89\u88c5Python\n\u68c0\u67e5VPS\u4e0aPython\u7684\u7248\u672c\u4fe1\u606f\uff0c\u67e5\u8be2\u547d\u4ee4\uff1apython --version \u6216 python3 --version\u3002\u82e5\u7248\u672c\u53f7\u5c0f\u4e8e3.5.0\uff0c\u5219\u9700\u5b89\u88c5\u65b0\u7248Python\n\u8fd9\u91cc\u4ee5Debian\/Ubuntu\u7cfb\u7edf\u4e3a\u4f8b\uff0c\u7f16\u8bd1\u5b89\u88c5Python 3.8.10\uff0c\u5e76\u66ff\u6362python3\u3001pip3\u7684\u73af\u5883\u53d8\u91cf\u3002\u8bf7\u6839\u636e\u81ea\u5df1VPS\u7684\u5b9e\u9645\u60c5\u51b5\u914d\u7f6e\u73af\u5883<\/p>\n<div class=\"blockcode\">\n<div id=\"code_gw3\">\n<ol>\n<li>apt-get update<\/li>\n<li>apt-get install build-essential -y<\/li>\n<li>apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev -y<\/li>\n<li>apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev -y<\/li>\n<li>apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev -y<\/li>\n<li>apt-get install ca-certificates -y<\/li>\n<li>apt-get install libsqlite3-dev -y<\/li>\n<li><\/li>\n<li>wget https:\/\/www.python.org\/ftp\/python\/3.8.10\/Python-3.8.10.tar.xz<\/li>\n<li>tar -Jxvf Python-3.8.10.tar.xz<\/li>\n<li>cd Python-3.8.10<\/li>\n<li>.\/configure<\/li>\n<li>make &amp;&amp; make install<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>2\u3001\u5b89\u88c5Telethon<\/p>\n<div class=\"blockcode\">\n<div id=\"code_CbO\">\n<ol>\n<li>pip3 install telethon<\/li>\n<\/ol>\n<\/div>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em><\/div>\n<p><strong>\u4e94\u3001\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff08Python\u7248\uff09<\/strong>\n1\u3001\u590d\u5236\u4ee5\u4e0b\u4ee3\u7801\uff0c\u6839\u636e\u9700\u8981\u4fee\u65396\u30017\u300114\u300116\u884c\uff0c\u4fdd\u5b58\u4e3atgsign.py\n\uff08\u4ee3\u7801\u88ab\u7cfb\u7edf\u548c\u8c10\uff0c\u89c1\u9644\u4ef6\uff09\n<img loading=\"lazy\" decoding=\"async\" id=\"aimg_n8Z8o\" class=\"zoom\" src=\"https:\/\/maofun.com\/wp-content\/uploads\/2021\/07\/e44a7-7oaEK8u65jNpFtz.png\" width=\"600\" height=\"240\" border=\"0\" \/ alt=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c4\u5f20\u56fe\u7247\" title=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c4\u5f20\u56fe\u7247 | \u732b\u996d\" ><\/p>\n<p>2\u3001\u5148\u8fd0\u884c\u4e00\u6b21\u811a\u672c\uff0c\u8f93\u5165python3 tgsign.py\u56de\u8f66\uff0c\u6839\u636e\u63d0\u793a\u586b\u5199\u624b\u673a\u53f7\u4e0e\u9a8c\u8bc1\u7801\u3002\u6210\u529f\u540eTelethon\u4f1a\u5728\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u751f\u6210.session\u4f1a\u8bdd\u6587\u4ef6\uff0c\u4ee5\u540e\u5c31\u4e0d\u7528\u518d\u8f93\u5165\u9a8c\u8bc1\u7801\u4e86\uff08\u5982\u65e0\u6cd5\u751f\u6210\u4f1a\u8bdd\u6587\u4ef6\uff0c\u8bf7\u68c0\u67e5Python\u5185\u7f6e\u5e93sqlite3\u662f\u5426\u5df2\u6b63\u5e38\u5b89\u88c5\uff09\n<img loading=\"lazy\" decoding=\"async\" id=\"aimg_fHl92\" class=\"zoom\" src=\"https:\/\/maofun.com\/wp-content\/uploads\/2021\/07\/37412-9RVTjhHEo4LDiAN.png\" width=\"600\" height=\"155\" border=\"0\" \/ alt=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c5\u5f20\u56fe\u7247\" title=\"TG\u81ea\u52a8\u7b7e\u5230\u811a\u672c\uff0c\u652f\u6301\u591a\u8d26\u53f7 - \u7b2c5\u5f20\u56fe\u7247 | \u732b\u996d\" ><\/p>\n<p>3\u3001\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\n\u8f93\u5165crontab -e\u8fdb\u5165\u5b9a\u65f6\u4efb\u52a1\u7f16\u8f91\u5668\uff0c\u6dfb\u52a0\uff1a\uff08\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\uff0c\u5982python\u8def\u5f84\u3001\u811a\u672c\u6587\u4ef6\u5b58\u653e\u8def\u5f84\u7b49\uff09<\/p>\n<div class=\"blockcode\">\n<div id=\"code_ijF\">\n<ol>\n<li>0 6 * * * cd \/root &amp;&amp; \/usr\/local\/bin\/python3 tgsign.py<\/li>\n<\/ol>\n<\/div>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u7b80\u4ecb TG\u4e0a\u7684\u67d0\u4e9b\u673a\u5668\u4eba\u7ecf\u5e38\u4f1a\u6709\u6bcf\u65e5\u7b7e\u5230\u62ff\u79ef\u5206\u7684\u6d3b\u52a8\uff0c\u867d\u8bf4\u6bcf\u5929\u4e0a\u53f7\u70b9\u4e00\u70b9\u4e5f\u4e0d\u9ebb\u70e6\uff0c\u4f46\u65f6\u95f4\u4e45\u4e86\u5c31\u7ecf\u5e38\u4f1a\u5fd8\u8bb0\u3002\u672c\u6559\u7a0b\u5c06\u5206\u4eab\u4e00\u79cd\u6bd4\u8f83\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u57fa\u4e8eTG API\u4ee5\u53caPython\u7684\u7b2c\u4e09\u65b9\u5305Telethon\uff0c\u90e8\u7f72\u5230VPS\u4e0a\uff0c\u6bcf\u5929\u5b9a\u65f6\u4e0aTG\u81ea\u52a8\u7b7e\u5230 \u4e8c\u3001\u51c6\u5907\u5de5\u4f5c 1\u3001\u5df2\u5f00\u542fAPI\u7684TG\u53f7\uff08\u4e0b\u9762\u4f1a\u8bb2\u8ff0\u5982\u4f55\u5f00\u542fTG API\uff09 2\u3001\u56fd\u5916VPS\u4e00\u53f0\uff08\u6216\u80fd\u9b54\u6cd5\u4e0a\u7f51\u7684\u8f6f\u8def\u7531\uff09 3\u3001Python 3.5+ \u4e09\u3001\u5f00\u542fTG API \u7533\u8bf7\u7f51\u5740\uff1ahttps:\/\/my.telegram.org 1\u3001\u8f93\u5165\u624b\u673a\u53f7\u767b\u5f55\uff0c\u6ce8\u610f\u9a8c\u8bc1\u7801\u4f1a\u53d1\u9001\u81f3TG\u5ba2\u6237\u7aef\u800c\u4e0d\u4f1a\u4ee5\u77ed\u4fe1\u5f62\u5f0f\u53d1\u9001 2\u3001\u767b\u5f55\u8fdb\u53bb\u540e\u9009\u201cAPI development tools\u201d&#8230;&#8230;<span class=\"read-more\"> <a href=\"https:\/\/maofun.com\/1774.html\"><\/p>\n<p>\u7ee7\u7eed\u9605\u8bfb&raquo;&raquo;&raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[435,437,436],"_links":{"self":[{"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/posts\/1774"}],"collection":[{"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/comments?post=1774"}],"version-history":[{"count":0,"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/posts\/1774\/revisions"}],"wp:attachment":[{"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/media?parent=1774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/categories?post=1774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maofun.com\/wp-json\/wp\/v2\/tags?post=1774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}