{"id":157,"date":"2023-06-13T23:58:46","date_gmt":"2023-06-13T15:58:46","guid":{"rendered":"https:\/\/www.mtqzone.com\/?p=157"},"modified":"2023-06-13T23:58:46","modified_gmt":"2023-06-13T15:58:46","slug":"%e5%9c%a8-tg-%e4%b8%ad%e8%8e%b7%e5%8f%96%e6%90%ac%e7%93%a6%e5%b7%a5-vps-%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/www.mtqzone.com\/index.php\/2023\/06\/13\/%e5%9c%a8-tg-%e4%b8%ad%e8%8e%b7%e5%8f%96%e6%90%ac%e7%93%a6%e5%b7%a5-vps-%e4%bf%a1%e6%81%af\/","title":{"rendered":"\u5728 TG \u4e2d\u83b7\u53d6\u642c\u74e6\u5de5 vps \u4fe1\u606f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5229\u7528\u642c\u74e6\u5de5\u7684 api \u548c pyrogram\uff0c\u5373\u53ef\u5728\u4efb\u610f\u5bf9\u8bdd\u4e2d\u83b7\u53d6 vps \u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5b89\u88c5 python3 \u548c pyrogram<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install python3 python3-pip \r\npip3 install -U pyrogram tgcrypto requests<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u811a\u672c\u4ee3\u7801\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env python3\r\n#-*-coding:utf-8-*-\r\n\r\nimport os\r\nimport time\r\nimport requests\r\nfrom pyrogram import Client, filters\r\n\r\n# \u5728\u642c\u74e6\u5de5\u540e\u53f0\u83b7\u53d6 veid \u548c api_key\r\nveid = '0000000'\r\napi_key = 'private_1234567890zxcvbn'\r\n\r\n# \u5728 https:\/\/my.telegram.org\/ \u767b\u5165\u81ea\u5df1\u7684 tg \u8d26\u53f7\u7533\u8bf7 api_id\u3001api_hash\r\napi_id = '00000000'\r\napi_hash = '1234567890zxcvbnm'\r\n\r\ndef bwh_info():\r\n  LiveServiceInfo = requests.get(url=f'https:\/\/api.64clouds.com\/v1\/getLiveServiceInfo?veid={veid}&amp;api_key={api_key}')\r\n  node_datacenter = LiveServiceInfo.json()&#91;'node_datacenter']\r\n  ve_status = LiveServiceInfo.json()&#91;'ve_status']\r\n  load_average = LiveServiceInfo.json()&#91;'load_average']\r\n  mem_available = str(LiveServiceInfo.json()&#91;'mem_available_kb'] \/ 1000)\r\n  plan_ram = str(LiveServiceInfo.json()&#91;'plan_ram'] \/ 1024 \/ 1024)\r\n  ve_used_disk_space = str(round(LiveServiceInfo.json()&#91;'ve_used_disk_space_b'] \/ 1024 \/ 1024 \/ 1024,2))\r\n  ve_disk_quota_gb = LiveServiceInfo.json()&#91;'ve_disk_quota_gb']\r\n  monthly_data_multiplier = LiveServiceInfo.json()&#91;'monthly_data_multiplier']\r\n  data_counter = str(round(LiveServiceInfo.json()&#91;'data_counter'] * monthly_data_multiplier \/ 1024 \/ 1024 \/ 1024,2))\r\n  plan_monthly_data = str(round(LiveServiceInfo.json()&#91;'plan_monthly_data'] \/ 1024 \/ 1024 \/ 1024,2))\r\n  data_next_reset = time.strftime(\"%Y-%m-%d\", time.localtime(LiveServiceInfo.json()&#91;'data_next_reset']))\r\n  text = f'**{node_datacenter}**\\n\\n'   \r\n  text += f'\u72b6\u6001\uff1a`{ve_status},{load_average}`\\n'\r\n  text += f'\u5185\u5b58\uff08\u53ef\u7528\uff09\uff1a`{mem_available}\/{plan_ram}MB`\\n'\r\n  text += f'\u786c\u76d8\uff08\u5df2\u7528\uff09\uff1a`{ve_used_disk_space}\/{ve_disk_quota_gb}GB`\\n'\r\n  text += f'\u6d41\u91cf\uff08\u5df2\u7528\uff09\uff1a`{data_counter}\/{plan_monthly_data}GB`\\n'\r\n  text += f'\u6d41\u91cf\u91cd\u7f6e\u65e5\u671f\uff1a`{data_next_reset}`\\n'\r\n  return text\r\n\r\napp = Client(f'{os.path.dirname(os.path.abspath(__file__))}\/{os.path.splitext(os.path.basename(__file__))&#91;0]}', api_id=api_id, api_hash=api_hash)\r\n\r\n@app.on_message(filters.me &amp; ~filters.forwarded &amp; filters.command('bwh', prefixes='\/'))\r\nasync def hello(client, message):\r\n  await message.edit_text(\"\u83b7\u53d6\u4e2d...\")\r\n  await message.edit_text(bwh_info())\r\n\r\napp.run()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c06\u4ee5\u4e0a\u5185\u5bb9\u4fdd\u5b58\u4e3a\u811a\u672c\u5982 <code>bwh.py<\/code>\uff0c\u7136\u540e\u8fd0\u884c\u3001\u6309\u7167\u63d0\u793a\u767b\u5f55\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5229\u7528\u642c\u74e6\u5de5\u7684 api \u548c pyrogra&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":1,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mtqzone.com\/index.php\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}