[
  {
    "path": ".edgeone/project.json",
    "content": "{\n  \"Name\": \"tg-message\",\n  \"ProjectId\": \"pages-ywhm4l7gjx2i\"\n}"
  },
  {
    "path": ".gitignore",
    "content": ".vercel\n.idea\n.idea/\n# Tencent Cloud EdgeOne\n.env\n.edgeone/*\n!.edgeone/project.json\n.tef_dist/*\n  "
  },
  {
    "path": "LICENSE",
    "content": "                        Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fanhao%2FTGMessage)\n[![Deploy to PandaStack](https://dashboard.pandastack.io/deploy-button.svg)](https://dashboard.pandastack.io/deploy?repo=anhao/TgMessage&type=static&buildCmd=npm+run+build&outputDir=dist)\n\n[![使用 EdgeOne Pages 部署](https://cdnstatic.tencentcs.com/edgeone/pages/deploy.svg)](https://edgeone.ai/pages/new?repository-url=https%3A%2F%2Fgithub.com%2Fanhao%2FTGMessage&project-name=tg-message&build-command=&install-command=&output-directory=edge_deploy&root-directory=./&env=token,sign_key&env-description=)\n\n## 技术赞助\n\n本项目 CDN 加速及安全防护由 Tencent EdgeOne 赞助：EdgeOne 提供长期有效的免费套餐，包含不限量的流量和请求，覆盖中国大陆节点，且无任何超额收费，感兴趣的朋友可以点击下面的链接领取\n\n[亚洲最佳CDN、边缘和安全解决方案 - Tencent EdgeOne](https://edgeone.ai/zh?from=github&utm_source=TgMessage)\n\n\n<a href=\"https://edgeone.ai/?utm_source=TgMessage\">\n  <img width=\"200\" src=\"https://edgeone.ai/media/34fe3a45-492d-4ea4-ae5d-ea1087ca7b4b.png\" alt=\"Tencent EdgeOne\">\n</a>\n\n## 第一步：创建 Telegram 机器人 (公共教程)\n\n在部署之前，您首先需要一个 Telegram Bot。\n\n1.  **关注 BotFather**: 在 Telegram 中搜索并关注官方的 [BotFather](https://t.me/BotFather)。\n2.  **创建机器人**: \n    *   向 BotFather 发送 `/newbot` 命令。\n    *   根据提示，依次输入机器人的显示名称（例如 `我的消息助手`）和用户名（必须以 `bot` 结尾，例如 `my_message_assistant_bot`）。\n    ![oEENc.png](/img/img.png)\n3.  **获取 Token**: 创建成功后，BotFather 会发送一条包含 **API Token** 的消息。请务必保存好这个 Token，它在后续部署中是必需的。\n    ![oEGEr.png](/img/img_1.png)\n4.  **设置命令**: 为了方便获取 `chat_id`，需要为机器人设置一个命令。\n    *   向 BotFather 发送 `/mybots`，然后选择你刚刚创建的机器人。\n    *   点击 `Edit Bot` -> `Edit Commands`。\n    *   输入 `token - 获取个人 Token` 并发送。\n    ![oEQIM.png](/img/img_2.png)\n\n---\n\n## 第二步：选择平台进行部署\n\n您可以选择 Vercel 或 腾讯云 EdgeOne 进行部署，两者择一即可。\n\n### 选项 A：通过 Vercel 部署\n\nVercel 提供免费、快速的 Serverless 函数托管服务。\n\n1.  **一键部署**: 点击项目顶部的 **Deploy with Vercel** 按钮。\n2.  **设置环境变量**: 在 Vercel 的项目创建页面，你需要配置以下环境变量：\n    *   `token`: **【必填】** 填入上一步获取的机器人 API Token。\n    *   `sign_key`: **【建议】** 用于加密 `chat_id` 的密钥，不设置默认为 `abc`。建议设置为一个复杂的随机字符串。\n    *   `key`: **【建议】** 设置 Webhook 时的管理密钥，防止他人调用。请设置为一个复杂的随机字符串。\n    *   `url`: **【可选】** 你的 Webhook 回调地址。如果不设置，后续需要手动指定。Webhook 最终地址为 `https://<你的Vercel域名>/api/webhook`。\n    ![oSJRB.png](/img/img_12.png)\n3.  **获取个人 Token**:\n    *   部署完成后，在浏览器中访问 `https://<你的Vercel域名>/api/setWebhook?key=<你设置的key>` 来设置回调。\n    *   然后与你的机器人对话，发送 `/token` 命令，机器人会返回一长串加密的个人 Token。\n4.  **发送消息**:\n    *   现在你可以通过请求 `https://<你的Vercel域名>/api/index?token=<你的个人Token>&message=你好` 来给自己发送消息。\n\n### 选项 B：通过 EdgeOne Page Functions 部署\n\nEdgeOne 是腾讯云推出的边缘一体化安全与加速平台，其 Page Functions 功能同样可以托管本项目。\n![edge_image](/img/edge_image_1.png)\n1.  **一键部署 (推荐)**:\n    *   点击项目顶部的 **使用 EdgeOne Pages 部署** 按钮。\n    *   授权后，在项目创建页面，EdgeOne 会自动为你填充大部分配置。\n    *   在 **环境变量** 部分，填入 `token` 和 `sign_key`。\n    *   **重要**: 部署启动后，请立即进入项目 \"设置\" -> \"环境变量\" 页面，**手动添加**第三个环境变量 `key`。\n    *   **环境变量说明**:\n        *   `token`: **【必填】** 你的 Telegram Bot Token。\n        *   `sign_key`: **【必填】** 加密 `chat_id` 用的密钥。\n        *   `key`: **【必填】** 设置 Webhook 用的管理密钥。\n2.  **手动部署**:\n    *   Fork 本项目到你的 GitHub 账户。\n    *   在 EdgeOne 控制台新建 Pages 项目，关联你 Fork 的仓库。\n    *   **输出目录** 填写 `edge_deploy`。\n    *   手动添加上述三个环境变量。\n3.  **获取个人 Token**:\n    *   部署成功后，在浏览器中访问 `https://<你的Pages域名>/setWebhook?key=<你设置的key>` 设置回调。\n    *   与你的机器人对话，发送 `/token` 命令，获取个人 Token。\n4.  **发送消息**:\n    *   通过访问 `https://<你的Pages域名>/sendMessage?token=<你的个人Token>&message=你好` 发送消息。\n    *   API 详情可参考 `edge_deploy/edge.html`。\n\n## Vercel 版本\n\nTG 消息推送机器人,基于 vercel 函数 和 Edgeone 边缘函数 搭建的TG消息推送机器人，无需服务器。\n\n## 搭建教程\n### Deploy to Vercel\n[![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fanhao%2FTgMessage&env=token,sign_key,key&project-name=tg-message&repo-name=tg-message&demo-title=TG%20Message&demo-url=https%3A%2F%2Ftg-message.vercel.app%2F)\n[![Deploy to PandaStack](https://dashboard.pandastack.io/deploy-button.svg)](https://dashboard.pandastack.io/deploy?repo=anhao/TgMessage&type=static&buildCmd=npm+run+build&outputDir=dist)\n### 建立 TG 机器人\n\n1.首先关注 [BotFather](https://t.me/BotFather)\n\n2. 创建机器人,关注 BotFather 之后,发送 `/newboot` 开始创建 Bot 第一次输入机器人名称,第二次输入机器人 `username` 需要以 `bot` 结尾\n   ![oEENc.png](/img/img.png)\n\n**3.获取机器人 token**\n\n创建成功之后会发送一条消息给你，里面就包含了 `token`\n\n![oEGEr.png](/img/img_1.png)\n\n**设置机器人 Command**\n设置获取 token 命令 首先给 BotFather 发送 `/mybots`,然后点击你刚才创建的机器人,再点击 `Edit Bot`, 继续点击 `Edit Commands`。 然后输入\n\n```\ntoken - 获取token\n```\n\n这样就设置好了一个 `commands`\n\n![oEQIM.png](/img/img_2.png)\n![oE0FG.png](/img/img_3.png)\n![oEcR1.png](/img/img_4.png)\n![oEd9I.png](/img/img_5.png)\n\n\n## 部署到 Vercel\n\n点击首页的 Deploy 跳到 vercel\n![oSgul.png](/img/img_10.png)\n\n输入项目名，然后确认\n\n![oSpFg.png](/img/img_11.png)\n\n确认之后会直接部署到 vercel\n\n### 设置环境变量\n\nvercel 部署好了之后，然后设置环境变量\n\n在控制台点击你创建好的项目，然后点击设置，添加环境变量\n\n![设置vercel 环境变量](/img/img_12.png)\n\n```\n需要设置4个环境变量，1个是必填的\n\ntoken: bot 机器人的token\nsign_key: 加密 chat_id 需要用到，不设置默认为 abc\nurl: webhook 回调地址, 不设置的话请求 setWebhook 时需要手动加参数， webhook url 地址为：https://你的域名/webhook\nkey: 设置 webhook 的请求参数\n```\n\n![oSJRB.png](/img/img_12.png)\n\n上面的环境变量设置好了之后，可能不会立马生效，你可以重新构建一下函数\n\n![oSP9s.png](/img/img_13.png)\n\n### 设置回调\n设置 webhook ，可以直接通过浏览器请求来设置\n\nwebhook地址为：`https://你的域名/webhook`\n\n浏览器窗口打开：`https://你的域名/setwebhook?key=环境变量设置的KEY&url=你的webhook地址`\n\n`code` 返回 200 就是设置成功了~\n"
  },
  {
    "path": "api/Bot.php",
    "content": "<?php\n\n/**\n * 简单封装 tg bot 请求\n * Class Bot\n * @author Alone88\n * @link https://alone88.cn\n */\nclass Bot\n{\n    // chat_id sign key\n    private string $key;\n    //Bot Token\n    private string $token;\n\n    public function __construct()\n    {\n        $this->token = $_ENV['token'];\n        $this->key = $_ENV['sign_key'] ?? 'abc';\n    }\n\n    public function request($method, $data)\n    {\n        $curl = curl_init();\n\n        curl_setopt_array($curl, array(\n            CURLOPT_URL => sprintf('https://api.telegram.org/bot%s/%s', $this->token, $method),\n            CURLOPT_RETURNTRANSFER => true,\n            CURLOPT_ENCODING => '',\n            CURLOPT_MAXREDIRS => 10,\n            CURLOPT_TIMEOUT => 0,\n            CURLOPT_FOLLOWLOCATION => true,\n            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n            CURLOPT_CUSTOMREQUEST => 'POST',\n            CURLOPT_POSTFIELDS => $data,\n        ));\n        $response = curl_exec($curl);\n        curl_close($curl);\n        return json_decode($response, true);\n    }\n\n    public function sendMessage($data): array\n    {\n        return $this->request('sendMessage', $data);\n    }\n\n    public function setWebHook($data)\n    {\n        return $this->request('setWebhook', $data);\n    }\n\n    public function encryption($chat_id): string\n    {\n        return base64_encode($this->key . $chat_id);\n    }\n\n    public function decryption($text): string\n    {\n        return substr(base64_decode($text), strlen($this->key));\n    }\n\n    /**\n     * @param string $key\n     * @return Bot\n     */\n    public function setKey(string $key): Bot\n    {\n        $this->key = $key;\n        return $this;\n    }\n\n    /**\n     * @param string $token\n     * @return Bot\n     */\n    public function setToken(string $token): Bot\n    {\n        $this->token = $token;\n        return $this;\n    }\n}"
  },
  {
    "path": "api/index.php",
    "content": "<?php\nrequire_once 'Bot.php';\n\nheader('content-type: application/json');\n$token = $_REQUEST['token'] ?? null;\n$message = $_REQUEST['message'] ?? '';\n\n$bot = new Bot();\n\nif (is_null($token)) {\n    echo json_encode(['code' => 422, 'message' => 'token 不能为空']);\n} else {\n    // 发送消息\n    $chat_id = $bot->decryption($token);\n    $ret = $bot->sendMessage(['text' => $message, 'chat_id' => $chat_id]);\n    if ($ret['ok']) {\n        echo json_encode(['code' => 200, 'message' => 'success']);\n    } else {\n        echo json_encode(['code' => 422, 'message' => $ret['description']]);\n    }\n}"
  },
  {
    "path": "api/setWebHook.php",
    "content": "<?php\nheader('content-type: application/json');\n\n$key = $_REQUEST['key'] ?? '';\n\nif ($key !== $_ENV['key']) {\n    echo json_encode(['code' => 422, 'message' => '设置秘钥错误']);\n} else {\n    //开始设置回调url\n    $url = $_REQUEST['url'] ?? $_ENV['url'];\n    require_once 'Bot.php';\n    $data = ['url' => $url];\n    $bot = new Bot();\n    $ret = $bot->setWebHook($data);\n    if ($ret['ok']) {\n        echo json_encode(['code' => 200, 'message' => '设置成功']);\n    } else {\n        echo json_encode(['code' => 422, 'message' => $ret['description']]);\n    }\n}"
  },
  {
    "path": "api/webhook.php",
    "content": "<?php\nheader('content-type: application/json');\nrequire_once 'Bot.php';\n$bot = new Bot();\n// 获取/token 命令，获取聊天 id\n$data = json_decode(file_get_contents(\"php://input\"), true);\n$message = $data['message']['text'] ?? '';\nif ($message === '/token') {\n    $chat_id = $data['message']['chat']['id'];\n    $bot->sendMessage(['text' => $bot->encryption($chat_id), 'chat_id' => $chat_id]);\n}\necho json_encode(['code' => 200, 'message' => 'success']);"
  },
  {
    "path": "edge_deploy/edge.html",
    "content": "<!doctype html>\n<html>\n<head>\n    <meta charset=\"utf-8\">\n    <title>TG 消息推送机器人 - 边缘函数版</title>\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta content=\"\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta name=\"keywords\" content=\"TG,机器人,telegram,提醒,消息,通知,边缘函数,Edge Functions\" />\n    <meta name=\"description\" content=\"一个由腾讯云边缘函数驱动的Telegram提醒机器人,server酱的telegram版,服务稳定,无依赖,可长期使用\" />\n    <style type=\"text/css\">/*! normalize.css v3.0.1 | MIT License | git.io/normalize */\n\n    /**\n     * 1. Set default font family to sans-serif.\n     * 2. Prevent iOS text size adjust after orientation change, without disabling\n     *    user zoom.\n     */\n\n    html {\n        font-family: sans-serif; /* 1 */\n        -ms-text-size-adjust: 100%; /* 2 */\n        -webkit-text-size-adjust: 100%; /* 2 */\n    }\n\n    /**\n     * Remove default margin.\n     */\n\n    body {\n        margin: 0;\n    }\n\n    /* HTML5 display definitions\n       ========================================================================== */\n\n    /**\n     * Correct `block` display not defined for any HTML5 element in IE 8/9.\n     * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.\n     * Correct `block` display not defined for `main` in IE 11.\n     */\n\n    article,\n    aside,\n    details,\n    figcaption,\n    figure,\n    footer,\n    header,\n    hgroup,\n    main,\n    nav,\n    section,\n    summary {\n        display: block;\n    }\n\n    /**\n     * 1. Correct `inline-block` display not defined in IE 8/9.\n     * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.\n     */\n\n    audio,\n    canvas,\n    progress,\n    video {\n        display: inline-block; /* 1 */\n        vertical-align: baseline; /* 2 */\n    }\n\n    /**\n     * Prevent modern browsers from displaying `audio` without controls.\n     * Remove excess height in iOS 5 devices.\n     */\n\n    audio:not([controls]) {\n        display: none;\n        height: 0;\n    }\n\n    /**\n     * Address `[hidden]` styling not present in IE 8/9/10.\n     * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.\n     */\n\n    [hidden],\n    template {\n        display: none;\n    }\n\n    /* Links\n       ========================================================================== */\n\n    /**\n     * Remove the gray background color from active links in IE 10.\n     */\n\n    a {\n        background: transparent;\n    }\n\n    /**\n     * Improve readability when focused and also mouse hovered in all browsers.\n     */\n\n    a:active,\n    a:hover {\n        outline: 0;\n    }\n\n    /* Text-level semantics\n       ========================================================================== */\n\n    /**\n     * Address styling not present in IE 8/9/10/11, Safari, and Chrome.\n     */\n\n    abbr[title] {\n        border-bottom: 1px dotted;\n    }\n\n    /**\n     * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.\n     */\n\n    b,\n    strong {\n        font-weight: bold;\n    }\n\n    /**\n     * Address styling not present in Safari and Chrome.\n     */\n\n    dfn {\n        font-style: italic;\n    }\n\n    /**\n     * Address variable `h1` font-size and margin within `section` and `article`\n     * contexts in Firefox 4+, Safari, and Chrome.\n     */\n\n    h1 {\n        font-size: 2em;\n        margin: 0.67em 0;\n    }\n\n    /**\n     * Address styling not present in IE 8/9.\n     */\n\n    mark {\n        background: #ff0;\n        color: #000;\n    }\n\n    /**\n     * Address inconsistent and variable font size in all browsers.\n     */\n\n    small {\n        font-size: 80%;\n    }\n\n    /**\n     * Prevent `sub` and `sup` affecting `line-height` in all browsers.\n     */\n\n    sub,\n    sup {\n        font-size: 75%;\n        line-height: 0;\n        position: relative;\n        vertical-align: baseline;\n    }\n\n    sup {\n        top: -0.5em;\n    }\n\n    sub {\n        bottom: -0.25em;\n    }\n\n    /* Embedded content\n       ========================================================================== */\n\n    /**\n     * Remove border when inside `a` element in IE 8/9/10.\n     */\n\n    img {\n        border: 0;\n    }\n\n    /**\n     * Correct overflow not hidden in IE 9/10/11.\n     */\n\n    svg:not(:root) {\n        overflow: hidden;\n    }\n\n    /* Grouping content\n       ========================================================================== */\n\n    /**\n     * Address margin not present in IE 8/9 and Safari.\n     */\n\n    figure {\n        margin: 1em 40px;\n    }\n\n    /**\n     * Address differences between Firefox and other browsers.\n     */\n\n    hr {\n        -moz-box-sizing: content-box;\n        box-sizing: content-box;\n        height: 0;\n    }\n\n    /**\n     * Contain overflow in all browsers.\n     */\n\n    pre {\n        overflow: auto;\n    }\n\n    /**\n     * Address odd `em`-unit font size rendering in all browsers.\n     */\n\n    code,\n    kbd,\n    pre,\n    samp {\n        font-family: monospace, monospace;\n        font-size: 1em;\n    }\n\n    /* Forms\n       ========================================================================== */\n\n    /**\n     * Known limitation: by default, Chrome and Safari on OS X allow very limited\n     * styling of `select`, unless a `border` property is set.\n     */\n\n    /**\n     * 1. Correct color not being inherited.\n     *    Known issue: affects color of disabled elements.\n     * 2. Correct font properties not being inherited.\n     * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.\n     */\n\n    button,\n    input,\n    optgroup,\n    select,\n    textarea {\n        color: inherit; /* 1 */\n        font: inherit; /* 2 */\n        margin: 0; /* 3 */\n    }\n\n    /**\n     * Address `overflow` set to `hidden` in IE 8/9/10/11.\n     */\n\n    button {\n        overflow: visible;\n    }\n\n    /**\n     * Address inconsistent `text-transform` inheritance for `button` and `select`.\n     * All other form control elements do not inherit `text-transform` values.\n     * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.\n     * Correct `select` style inheritance in Firefox.\n     */\n\n    button,\n    select {\n        text-transform: none;\n    }\n\n    /**\n     * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`\n     *    and `video` controls.\n     * 2. Correct inability to style clickable `input` types in iOS.\n     * 3. Improve usability and consistency of cursor style between image-type\n     *    `input` and others.\n     */\n\n    button,\n    html input[type=\"button\"], /* 1 */\n    input[type=\"reset\"],\n    input[type=\"submit\"] {\n        -webkit-appearance: button; /* 2 */\n        cursor: pointer; /* 3 */\n    }\n\n    /**\n     * Re-set default cursor for disabled elements.\n     */\n\n    button[disabled],\n    html input[disabled] {\n        cursor: default;\n    }\n\n    /**\n     * Remove inner padding and border in Firefox 4+.\n     */\n\n    button::-moz-focus-inner,\n    input::-moz-focus-inner {\n        border: 0;\n        padding: 0;\n    }\n\n    /**\n     * Address Firefox 4+ setting `line-height` on `input` using `!important` in\n     * the UA stylesheet.\n     */\n\n    input {\n        line-height: normal;\n    }\n\n    /**\n     * It's recommended that you don't attempt to style these elements.\n     * Firefox's implementation doesn't respect box-sizing, padding, or width.\n     *\n     * 1. Address box sizing set to `content-box` in IE 8/9/10.\n     * 2. Remove excess padding in IE 8/9/10.\n     */\n\n    input[type=\"checkbox\"],\n    input[type=\"radio\"] {\n        box-sizing: border-box; /* 1 */\n        padding: 0; /* 2 */\n    }\n\n    /**\n     * Fix the cursor style for Chrome's increment/decrement buttons. For certain\n     * `font-size` values of the `input`, it causes the cursor style of the\n     * decrement button to change from `default` to `text`.\n     */\n\n    input[type=\"number\"]::-webkit-inner-spin-button,\n    input[type=\"number\"]::-webkit-outer-spin-button {\n        height: auto;\n    }\n\n    /**\n     * 1. Address `appearance` set to `searchfield` in Safari and Chrome.\n     * 2. Address `box-sizing` set to `border-box` in Safari and Chrome\n     *    (include `-moz` to future-proof).\n     */\n\n    input[type=\"search\"] {\n        -webkit-appearance: textfield; /* 1 */\n        -moz-box-sizing: content-box;\n        -webkit-box-sizing: content-box; /* 2 */\n        box-sizing: content-box;\n    }\n\n    /**\n     * Remove inner padding and search cancel button in Safari and Chrome on OS X.\n     * Safari (but not Chrome) clips the cancel button when the search input has\n     * padding (and `textfield` appearance).\n     */\n\n    input[type=\"search\"]::-webkit-search-cancel-button,\n    input[type=\"search\"]::-webkit-search-decoration {\n        -webkit-appearance: none;\n    }\n\n    /**\n     * Define consistent border, margin, and padding.\n     */\n\n    fieldset {\n        border: 1px solid #c0c0c0;\n        margin: 0 2px;\n        padding: 0.35em 0.625em 0.75em;\n    }\n\n    /**\n     * 1. Correct `color` not being inherited in IE 8/9/10/11.\n     * 2. Remove padding so people aren't caught out if they zero out fieldsets.\n     */\n\n    legend {\n        border: 0; /* 1 */\n        padding: 0; /* 2 */\n    }\n\n    /**\n     * Remove default vertical scrollbar in IE 8/9/10/11.\n     */\n\n    textarea {\n        overflow: auto;\n    }\n\n    /**\n     * Don't inherit the `font-weight` (applied by a rule above).\n     * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.\n     */\n\n    optgroup {\n        font-weight: bold;\n    }\n\n    /* Tables\n       ========================================================================== */\n\n    /**\n     * Remove most spacing between table cells.\n     */\n\n    table {\n        border-collapse: collapse;\n        border-spacing: 0;\n    }\n\n    td,\n    th {\n        padding: 0;\n    }\n\n    /* mscore */\n    * {\n        -webkit-box-sizing: border-box;\n        -moz-box-sizing: border-box;\n        box-sizing: border-box;\n    }\n\n    *:before,\n    *:after {\n        -webkit-box-sizing: border-box;\n        -moz-box-sizing: border-box;\n        box-sizing: border-box;\n    }\n\n    html {\n        font-size: 62.5%;\n        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n    }\n\n    body {\n        /*font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;*/\n        font-family: 'Helvetica Neue', Helvetica, Arial, 'Microsoft Yahei', sans-serif;\n        font-size: 14px;\n        line-height: 1.42857143;\n        color: #333333;\n        background-color: #ffffff;\n    }\n\n    input,\n    button,\n    select,\n    textarea {\n        font-family: inherit;\n        font-size: inherit;\n        line-height: inherit;\n    }\n\n    a {\n        color: #428bca;\n        text-decoration: none;\n    }\n\n    a:hover,\n    a:focus {\n        color: #2a6496;\n        text-decoration: underline;\n    }\n\n    a:focus {\n        outline: thin dotted;\n        outline: 5px auto -webkit-focus-ring-color;\n        outline-offset: -2px;\n    }\n\n    figure {\n        margin: 0;\n    }\n\n    img {\n        vertical-align: middle;\n    }\n\n    /*\n    Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>\n    */\n\n    .hljs {\n        display: block;\n        overflow-x: auto;\n        padding: 0.5em;\n        background: #f0f0f0;\n        -webkit-text-size-adjust: none;\n    }\n\n    .hljs,\n    .hljs-subst,\n    .hljs-tag .hljs-title,\n    .nginx .hljs-title {\n        color: black;\n    }\n\n    .hljs-string,\n    .hljs-title,\n    .hljs-constant,\n    .hljs-parent,\n    .hljs-tag .hljs-value,\n    .hljs-rules .hljs-value,\n    .hljs-preprocessor,\n    .hljs-pragma,\n    .haml .hljs-symbol,\n    .ruby .hljs-symbol,\n    .ruby .hljs-symbol .hljs-string,\n    .hljs-template_tag,\n    .django .hljs-variable,\n    .smalltalk .hljs-class,\n    .hljs-addition,\n    .hljs-flow,\n    .hljs-stream,\n    .bash .hljs-variable,\n    .apache .hljs-tag,\n    .apache .hljs-cbracket,\n    .tex .hljs-command,\n    .tex .hljs-special,\n    .erlang_repl .hljs-function_or_atom,\n    .asciidoc .hljs-header,\n    .markdown .hljs-header,\n    .coffeescript .hljs-attribute {\n        color: #800;\n    }\n\n    .smartquote,\n    .hljs-comment,\n    .hljs-annotation,\n    .diff .hljs-header,\n    .hljs-chunk,\n    .asciidoc .hljs-blockquote,\n    .markdown .hljs-blockquote {\n        color: #888;\n    }\n\n    .hljs-number,\n    .hljs-date,\n    .hljs-regexp,\n    .hljs-literal,\n    .hljs-hexcolor,\n    .smalltalk .hljs-symbol,\n    .smalltalk .hljs-char,\n    .go .hljs-constant,\n    .hljs-change,\n    .lasso .hljs-variable,\n    .makefile .hljs-variable,\n    .asciidoc .hljs-bullet,\n    .markdown .hljs-bullet,\n    .asciidoc .hljs-link_url,\n    .markdown .hljs-link_url {\n        color: #080;\n    }\n\n    .hljs-label,\n    .hljs-javadoc,\n    .ruby .hljs-string,\n    .hljs-decorator,\n    .hljs-filter .hljs-argument,\n    .hljs-localvars,\n    .hljs-array,\n    .hljs-attr_selector,\n    .hljs-important,\n    .hljs-pseudo,\n    .hljs-pi,\n    .haml .hljs-bullet,\n    .hljs-doctype,\n    .hljs-deletion,\n    .hljs-envvar,\n    .hljs-shebang,\n    .apache .hljs-sqbracket,\n    .nginx .hljs-built_in,\n    .tex .hljs-formula,\n    .erlang_repl .hljs-reserved,\n    .hljs-prompt,\n    .asciidoc .hljs-link_label,\n    .markdown .hljs-link_label,\n    .vhdl .hljs-attribute,\n    .clojure .hljs-attribute,\n    .asciidoc .hljs-attribute,\n    .lasso .hljs-attribute,\n    .coffeescript .hljs-property,\n    .hljs-phony {\n        color: #88f;\n    }\n\n    .hljs-keyword,\n    .hljs-id,\n    .hljs-title,\n    .hljs-built_in,\n    .css .hljs-tag,\n    .hljs-javadoctag,\n    .hljs-phpdoc,\n    .hljs-dartdoc,\n    .hljs-yardoctag,\n    .smalltalk .hljs-class,\n    .hljs-winutils,\n    .bash .hljs-variable,\n    .apache .hljs-tag,\n    .hljs-type,\n    .hljs-typename,\n    .tex .hljs-command,\n    .asciidoc .hljs-strong,\n    .markdown .hljs-strong,\n    .hljs-request,\n    .hljs-status {\n        font-weight: bold;\n    }\n\n    .asciidoc .hljs-emphasis,\n    .markdown .hljs-emphasis {\n        font-style: italic;\n    }\n\n    .nginx .hljs-built_in {\n        font-weight: normal;\n    }\n\n    .coffeescript .javascript,\n    .javascript .xml,\n    .lasso .markup,\n    .tex .hljs-formula,\n    .xml .javascript,\n    .xml .vbscript,\n    .xml .css,\n    .xml .hljs-cdata {\n        opacity: 0.5;\n    }\n\n    #container {\n        padding: 15px;\n        margin-left: 20px;\n    }\n\n    pre {\n        border: 1px solid #ccc;\n        border-radius: 4px;\n        display: block;\n    }\n\n    pre code {\n        white-space: pre-wrap;\n    }\n\n    .hljs,\n    code {\n        font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;\n    }\n\n    pre {\n        background-color: #dddddd;\n        padding: 8px 0px 8px 30px;\n        word-wrap: break-word;\n    }\n\n    table tbody tr:nth-child(2n) {\n        background: rgba(158, 188, 226, 0.12);\n    }\n\n    :not(pre) > code {\n        padding: 2px 4px;\n        font-size: 90%;\n        color: #c7254e;\n        background-color: #f9f2f4;\n        white-space: nowrap;\n        border-radius: 4px;\n    }\n\n    th, td {\n        border: 1px solid #ccc;\n        padding: 6px 12px;\n    }\n\n    blockquote {\n        border-left-width: 10px;\n        background-color: rgba(102, 128, 153, 0.05);\n        border-top-right-radius: 5px;\n        border-bottom-right-radius: 5px;\n        padding: 1px 20px\n    }\n\n    blockquote.pull-right small:before, blockquote.pull-right .small:before {\n        content: ''\n    }\n\n    blockquote.pull-right small:after, blockquote.pull-right .small:after {\n        content: '\\00A0 \\2014'\n    }\n\n    blockquote:before, blockquote:after {\n        content: \"\"\n    }\n\n    blockquote {\n        margin: 0 0 1.1em\n    }\n\n    blockquote p {\n        margin-bottom: 1.1em;\n        font-size: 1em;\n        line-height: 1.45\n    }\n\n    blockquote ul:last-child, blockquote ol:last-child {\n        margin-bottom: 0\n    }\n\n    blockquote {\n        margin: 0 0 21px;\n        border-left: 10px solid #dddddd;\n    }</style>\n    <style type=\"text/css\" abt=\"234\"></style>\n    <input type=\"hidden\" id=\"_w_elixir\"></head>\n<body marginwidth=\"0\" marginheight=\"0\">\n<div id=\"container\">\n    <h2 id=\"-\">接口名称</h2>\n    <h3 id=\"1-\">1) 边缘函数地址</h3>\n    <blockquote>\n        <p>你的边缘函数触发地址, 例如： <code>https://your-domain.com/</code></p>\n    </blockquote>\n    <h3 id=\"2-http-get-post\">2) 调用方式：HTTP GET / POST</h3>\n    <h3 id=\"3-\">3) 接口描述：</h3>\n    <ul>\n        <li>TG版消息推送机器人, 由 <strong>腾讯云 Page Functions</strong> 强力驱动.</li>\n        <li>关注机器人 <a href=\"https://t.me/msg_sause_bot\">MessageBot</a> (或你自己的Bot).</li>\n        <li>向机器人发送 <code>/token</code> 获取你的专属 Token.</li>\n        <li>你需要在腾讯云控制台为你的边缘函数配置三个环境变量: <code>token</code>, <code>sign_key</code>, <code>key</code>.</li>\n    </ul>\n    <h3 id=\"4-\">4) 请求 API:</h3>\n\n    <h4>/sendMessage (发送消息)</h4>\n    <table>\n        <thead>\n        <tr>\n            <th>字段名称</th>\n            <th style=\"text-align:center\">类型</th>\n            <th style=\"text-align:center\">必填</th>\n            <th style=\"text-align:right\">备注</th>\n        </tr>\n        </thead>\n        <tbody>\n        <tr>\n            <td>token</td>\n            <td style=\"text-align:center\">string</td>\n            <td style=\"text-align:center\">Y</td>\n            <td style=\"text-align:right\">从机器人获取的 Token</td>\n        </tr>\n        <tr>\n            <td>message</td>\n            <td style=\"text-align:center\">string</td>\n            <td style=\"text-align:center\">Y</td>\n            <td style=\"text-align:right\">要发送的消息内容</td>\n        </tr>\n        </tbody>\n    </table>\n    <p>请求示例:</p>\n    <pre><code>GET /sendMessage?token=YOUR_TOKEN&message=Hello+World\n</code></pre>\n\n    <h4>/setWebhook (设置回调)</h4>\n    <table>\n        <thead>\n        <tr>\n            <th>字段名称</th>\n            <th style=\"text-align:center\">类型</th>\n            <th style=\"text-align:center\">必填</th>\n            <th style=\"text-align:right\">备注</th>\n        </tr>\n        </thead>\n        <tbody>\n        <tr>\n            <td>key</td>\n            <td style=\"text-align:center\">string</td>\n            <td style=\"text-align:center\">Y</td>\n            <td style=\"text-align:right\">你在环境变量中设置的 <code>key</code></td>\n        </tr>\n        <tr>\n            <td>url</td>\n            <td style=\"text-align:center\">string</td>\n            <td style-=\"text-align:center\">N</td>\n            <td style=\"text-align:right\">可选, 自定义 webhook 地址, 默认为当前函数地址 + <code>/webhook</code></td>\n        </tr>\n        </tbody>\n    </table>\n    <p>请求示例:</p>\n    <pre><code>GET /setWebhook?key=YOUR_ADMIN_KEY\n</code></pre>\n\n    <h4>/webhook (接收回调)</h4>\n    <p>此接口用于接收来自 Telegram 的 POST 请求，通常无需手动调用。</p>\n\n\n    <h3 id=\"5-\">5) 请求返回结果:</h3>\n    <pre><code>{\"code\":200,\"message\":\"success\"}\n</code></pre>\n</div>\n</body>\n</html> "
  },
  {
    "path": "edgeone.json",
    "content": "{\n    \"name\": \"TGMessage\",\n    \"outputDirectory\": \"./edge_deploy\"\n  }"
  },
  {
    "path": "functions/bot.js",
    "content": "class Bot {\n    // chat_id sign key\n    key;\n    //Bot Token\n    token;\n\n    constructor(env) {\n        this.token = env.token;\n        this.key = env.sign_key ?? 'abc';\n    }\n\n    async request(method, data) {\n        const url = `https://api.telegram.org/bot${this.token}/${method}`;\n        const response = await fetch(url, {\n            method: 'POST',\n            headers: {\n                'Content-Type': 'application/json'\n            },\n            body: JSON.stringify(data)\n        });\n        return await response.json();\n    }\n\n    async sendMessage(data) {\n        return this.request('sendMessage', data);\n    }\n\n    async setWebHook(data) {\n        return this.request('setWebhook', data);\n    }\n\n    encryption(chat_id) {\n        const text = this.key + chat_id;\n        return Buffer.from(text).toString('base64');\n    }\n\n    decryption(text) {\n        const decoded = Buffer.from(text, 'base64').toString('ascii');\n        return decoded.substring(this.key.length);\n    }\n}\n\nexport default Bot; "
  },
  {
    "path": "functions/sendMessage.js",
    "content": "import Bot from './bot.js';\n\nexport async function onRequest(context) {\n    const { request, env } = context;\n    const bot = new Bot(env);\n\n    let token, message;\n\n    if (request.method === 'POST') {\n        const contentType = request.headers.get('content-type') || '';\n        if (contentType.includes('application/json')) {\n            const body = await request.json();\n            token = body.token;\n            message = body.message;\n        } else if (contentType.includes('application/x-www-form-urlencoded') || contentType.includes('multipart/form-data')) {\n            const formData = await request.formData();\n            token = formData.get('token');\n            message = formData.get('message');\n        }\n    } else { // GET request\n        const url = new URL(request.url);\n        token = url.searchParams.get('token');\n        message = url.searchParams.get('message');\n    }\n\n    if (!token) {\n        return new Response(JSON.stringify({ code: 422, message: 'token 不能为空' }), {\n            headers: { 'Content-Type': 'application/json' },\n            status: 422\n        });\n    }\n\n    try {\n        const chat_id = bot.decryption(token);\n        const ret = await bot.sendMessage({ text: message, chat_id: chat_id });\n\n        if (ret.ok) {\n            return new Response(JSON.stringify({ code: 200, message: 'success' }), {\n                headers: { 'Content-Type': 'application/json' },\n                status: 200\n            });\n        } else {\n            return new Response(JSON.stringify({ code: 422, message: ret.description }), {\n                headers: { 'Content-Type': 'application/json' },\n                status: 422\n            });\n        }\n    } catch (e) {\n        return new Response(JSON.stringify({ code: 500, message: 'Token decryption failed or other server error.' }), {\n            headers: { 'Content-Type': 'application/json' },\n            status: 500\n        });\n    }\n} "
  },
  {
    "path": "functions/setWebhook.js",
    "content": "import Bot from './bot.js';\n\nexport async function onRequest(context) {\n    const { request, env } = context;\n    const bot = new Bot(env);\n    const url = new URL(request.url);\n\n    const key = url.searchParams.get('key');\n\n    if (key !== env.key) {\n        return new Response(JSON.stringify({ code: 401, message: 'unauthorized' }), {\n            headers: { 'Content-Type': 'application/json' },\n            status: 401\n        });\n    }\n\n    // Default webhook URL is the current function's host + /webhook\n    const webhookUrl = url.searchParams.get('url') || `https://${url.hostname}/webhook`;\n    \n    const ret = await bot.setWebHook({ url: webhookUrl });\n\n    if (ret.ok) {\n        return new Response(JSON.stringify({ code: 200, message: `Webhook set to ${webhookUrl}` }), {\n            headers: { 'Content-Type': 'application/json' }\n        });\n    } else {\n        return new Response(JSON.stringify({ code: 422, message: ret.description }), {\n            headers: { 'Content-Type': 'application/json' },\n            status: 422\n        });\n    }\n} "
  },
  {
    "path": "functions/webhook.js",
    "content": "import Bot from './bot.js';\n\nexport async function onRequest(context) {\n    const { request, env } = context;\n    const bot = new Bot(env);\n\n    if (request.method !== 'POST') {\n        return new Response('Please use POST method', { status: 405 });\n    }\n\n    try {\n        const data = await request.json();\n        const message = data.message?.text ?? '';\n\n        if (message === '/token') {\n            const chat_id = data.message.chat.id;\n            await bot.sendMessage({ text: bot.encryption(chat_id), chat_id: chat_id });\n        }\n    } catch (e) {\n        // Log the error but still return a success response to Telegram\n        // to avoid repeated webhook calls.\n        console.error(e);\n    }\n    \n    // Always return a success response to Telegram\n    return new Response(JSON.stringify({ code: 200, message: 'success' }), {\n        headers: { 'Content-Type': 'application/json' }\n    });\n} "
  },
  {
    "path": "index.html",
    "content": "<!doctype html>\n<html>\n<head>\n    <meta charset=\"utf-8\">\n    <title>TG 消息推送机器人</title>\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta content=\"\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta name=\"keywords\" content=\"TG,机器人,telegram,提醒,消息,通知,server酱,\" />\n    <meta name=\"description\" content=\"一个telegram提醒机器人,server酱的telegram版,搭建在vercel,服务稳定,无依赖,可长期使用\" />\n    <style type=\"text/css\">/*! normalize.css v3.0.1 | MIT License | git.io/normalize */\n\n    /**\n     * 1. Set default font family to sans-serif.\n     * 2. Prevent iOS text size adjust after orientation change, without disabling\n     *    user zoom.\n     */\n\n    html {\n        font-family: sans-serif; /* 1 */\n        -ms-text-size-adjust: 100%; /* 2 */\n        -webkit-text-size-adjust: 100%; /* 2 */\n    }\n\n    /**\n     * Remove default margin.\n     */\n\n    body {\n        margin: 0;\n    }\n\n    /* HTML5 display definitions\n       ========================================================================== */\n\n    /**\n     * Correct `block` display not defined for any HTML5 element in IE 8/9.\n     * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.\n     * Correct `block` display not defined for `main` in IE 11.\n     */\n\n    article,\n    aside,\n    details,\n    figcaption,\n    figure,\n    footer,\n    header,\n    hgroup,\n    main,\n    nav,\n    section,\n    summary {\n        display: block;\n    }\n\n    /**\n     * 1. Correct `inline-block` display not defined in IE 8/9.\n     * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.\n     */\n\n    audio,\n    canvas,\n    progress,\n    video {\n        display: inline-block; /* 1 */\n        vertical-align: baseline; /* 2 */\n    }\n\n    /**\n     * Prevent modern browsers from displaying `audio` without controls.\n     * Remove excess height in iOS 5 devices.\n     */\n\n    audio:not([controls]) {\n        display: none;\n        height: 0;\n    }\n\n    /**\n     * Address `[hidden]` styling not present in IE 8/9/10.\n     * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.\n     */\n\n    [hidden],\n    template {\n        display: none;\n    }\n\n    /* Links\n       ========================================================================== */\n\n    /**\n     * Remove the gray background color from active links in IE 10.\n     */\n\n    a {\n        background: transparent;\n    }\n\n    /**\n     * Improve readability when focused and also mouse hovered in all browsers.\n     */\n\n    a:active,\n    a:hover {\n        outline: 0;\n    }\n\n    /* Text-level semantics\n       ========================================================================== */\n\n    /**\n     * Address styling not present in IE 8/9/10/11, Safari, and Chrome.\n     */\n\n    abbr[title] {\n        border-bottom: 1px dotted;\n    }\n\n    /**\n     * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.\n     */\n\n    b,\n    strong {\n        font-weight: bold;\n    }\n\n    /**\n     * Address styling not present in Safari and Chrome.\n     */\n\n    dfn {\n        font-style: italic;\n    }\n\n    /**\n     * Address variable `h1` font-size and margin within `section` and `article`\n     * contexts in Firefox 4+, Safari, and Chrome.\n     */\n\n    h1 {\n        font-size: 2em;\n        margin: 0.67em 0;\n    }\n\n    /**\n     * Address styling not present in IE 8/9.\n     */\n\n    mark {\n        background: #ff0;\n        color: #000;\n    }\n\n    /**\n     * Address inconsistent and variable font size in all browsers.\n     */\n\n    small {\n        font-size: 80%;\n    }\n\n    /**\n     * Prevent `sub` and `sup` affecting `line-height` in all browsers.\n     */\n\n    sub,\n    sup {\n        font-size: 75%;\n        line-height: 0;\n        position: relative;\n        vertical-align: baseline;\n    }\n\n    sup {\n        top: -0.5em;\n    }\n\n    sub {\n        bottom: -0.25em;\n    }\n\n    /* Embedded content\n       ========================================================================== */\n\n    /**\n     * Remove border when inside `a` element in IE 8/9/10.\n     */\n\n    img {\n        border: 0;\n    }\n\n    /**\n     * Correct overflow not hidden in IE 9/10/11.\n     */\n\n    svg:not(:root) {\n        overflow: hidden;\n    }\n\n    /* Grouping content\n       ========================================================================== */\n\n    /**\n     * Address margin not present in IE 8/9 and Safari.\n     */\n\n    figure {\n        margin: 1em 40px;\n    }\n\n    /**\n     * Address differences between Firefox and other browsers.\n     */\n\n    hr {\n        -moz-box-sizing: content-box;\n        box-sizing: content-box;\n        height: 0;\n    }\n\n    /**\n     * Contain overflow in all browsers.\n     */\n\n    pre {\n        overflow: auto;\n    }\n\n    /**\n     * Address odd `em`-unit font size rendering in all browsers.\n     */\n\n    code,\n    kbd,\n    pre,\n    samp {\n        font-family: monospace, monospace;\n        font-size: 1em;\n    }\n\n    /* Forms\n       ========================================================================== */\n\n    /**\n     * Known limitation: by default, Chrome and Safari on OS X allow very limited\n     * styling of `select`, unless a `border` property is set.\n     */\n\n    /**\n     * 1. Correct color not being inherited.\n     *    Known issue: affects color of disabled elements.\n     * 2. Correct font properties not being inherited.\n     * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.\n     */\n\n    button,\n    input,\n    optgroup,\n    select,\n    textarea {\n        color: inherit; /* 1 */\n        font: inherit; /* 2 */\n        margin: 0; /* 3 */\n    }\n\n    /**\n     * Address `overflow` set to `hidden` in IE 8/9/10/11.\n     */\n\n    button {\n        overflow: visible;\n    }\n\n    /**\n     * Address inconsistent `text-transform` inheritance for `button` and `select`.\n     * All other form control elements do not inherit `text-transform` values.\n     * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.\n     * Correct `select` style inheritance in Firefox.\n     */\n\n    button,\n    select {\n        text-transform: none;\n    }\n\n    /**\n     * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`\n     *    and `video` controls.\n     * 2. Correct inability to style clickable `input` types in iOS.\n     * 3. Improve usability and consistency of cursor style between image-type\n     *    `input` and others.\n     */\n\n    button,\n    html input[type=\"button\"], /* 1 */\n    input[type=\"reset\"],\n    input[type=\"submit\"] {\n        -webkit-appearance: button; /* 2 */\n        cursor: pointer; /* 3 */\n    }\n\n    /**\n     * Re-set default cursor for disabled elements.\n     */\n\n    button[disabled],\n    html input[disabled] {\n        cursor: default;\n    }\n\n    /**\n     * Remove inner padding and border in Firefox 4+.\n     */\n\n    button::-moz-focus-inner,\n    input::-moz-focus-inner {\n        border: 0;\n        padding: 0;\n    }\n\n    /**\n     * Address Firefox 4+ setting `line-height` on `input` using `!important` in\n     * the UA stylesheet.\n     */\n\n    input {\n        line-height: normal;\n    }\n\n    /**\n     * It's recommended that you don't attempt to style these elements.\n     * Firefox's implementation doesn't respect box-sizing, padding, or width.\n     *\n     * 1. Address box sizing set to `content-box` in IE 8/9/10.\n     * 2. Remove excess padding in IE 8/9/10.\n     */\n\n    input[type=\"checkbox\"],\n    input[type=\"radio\"] {\n        box-sizing: border-box; /* 1 */\n        padding: 0; /* 2 */\n    }\n\n    /**\n     * Fix the cursor style for Chrome's increment/decrement buttons. For certain\n     * `font-size` values of the `input`, it causes the cursor style of the\n     * decrement button to change from `default` to `text`.\n     */\n\n    input[type=\"number\"]::-webkit-inner-spin-button,\n    input[type=\"number\"]::-webkit-outer-spin-button {\n        height: auto;\n    }\n\n    /**\n     * 1. Address `appearance` set to `searchfield` in Safari and Chrome.\n     * 2. Address `box-sizing` set to `border-box` in Safari and Chrome\n     *    (include `-moz` to future-proof).\n     */\n\n    input[type=\"search\"] {\n        -webkit-appearance: textfield; /* 1 */\n        -moz-box-sizing: content-box;\n        -webkit-box-sizing: content-box; /* 2 */\n        box-sizing: content-box;\n    }\n\n    /**\n     * Remove inner padding and search cancel button in Safari and Chrome on OS X.\n     * Safari (but not Chrome) clips the cancel button when the search input has\n     * padding (and `textfield` appearance).\n     */\n\n    input[type=\"search\"]::-webkit-search-cancel-button,\n    input[type=\"search\"]::-webkit-search-decoration {\n        -webkit-appearance: none;\n    }\n\n    /**\n     * Define consistent border, margin, and padding.\n     */\n\n    fieldset {\n        border: 1px solid #c0c0c0;\n        margin: 0 2px;\n        padding: 0.35em 0.625em 0.75em;\n    }\n\n    /**\n     * 1. Correct `color` not being inherited in IE 8/9/10/11.\n     * 2. Remove padding so people aren't caught out if they zero out fieldsets.\n     */\n\n    legend {\n        border: 0; /* 1 */\n        padding: 0; /* 2 */\n    }\n\n    /**\n     * Remove default vertical scrollbar in IE 8/9/10/11.\n     */\n\n    textarea {\n        overflow: auto;\n    }\n\n    /**\n     * Don't inherit the `font-weight` (applied by a rule above).\n     * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.\n     */\n\n    optgroup {\n        font-weight: bold;\n    }\n\n    /* Tables\n       ========================================================================== */\n\n    /**\n     * Remove most spacing between table cells.\n     */\n\n    table {\n        border-collapse: collapse;\n        border-spacing: 0;\n    }\n\n    td,\n    th {\n        padding: 0;\n    }\n\n    /* mscore */\n    * {\n        -webkit-box-sizing: border-box;\n        -moz-box-sizing: border-box;\n        box-sizing: border-box;\n    }\n\n    *:before,\n    *:after {\n        -webkit-box-sizing: border-box;\n        -moz-box-sizing: border-box;\n        box-sizing: border-box;\n    }\n\n    html {\n        font-size: 62.5%;\n        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n    }\n\n    body {\n        /*font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;*/\n        font-family: 'Helvetica Neue', Helvetica, Arial, 'Microsoft Yahei', sans-serif;\n        font-size: 14px;\n        line-height: 1.42857143;\n        color: #333333;\n        background-color: #ffffff;\n    }\n\n    input,\n    button,\n    select,\n    textarea {\n        font-family: inherit;\n        font-size: inherit;\n        line-height: inherit;\n    }\n\n    a {\n        color: #428bca;\n        text-decoration: none;\n    }\n\n    a:hover,\n    a:focus {\n        color: #2a6496;\n        text-decoration: underline;\n    }\n\n    a:focus {\n        outline: thin dotted;\n        outline: 5px auto -webkit-focus-ring-color;\n        outline-offset: -2px;\n    }\n\n    figure {\n        margin: 0;\n    }\n\n    img {\n        vertical-align: middle;\n    }\n\n    /*\n    Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>\n    */\n\n    .hljs {\n        display: block;\n        overflow-x: auto;\n        padding: 0.5em;\n        background: #f0f0f0;\n        -webkit-text-size-adjust: none;\n    }\n\n    .hljs,\n    .hljs-subst,\n    .hljs-tag .hljs-title,\n    .nginx .hljs-title {\n        color: black;\n    }\n\n    .hljs-string,\n    .hljs-title,\n    .hljs-constant,\n    .hljs-parent,\n    .hljs-tag .hljs-value,\n    .hljs-rules .hljs-value,\n    .hljs-preprocessor,\n    .hljs-pragma,\n    .haml .hljs-symbol,\n    .ruby .hljs-symbol,\n    .ruby .hljs-symbol .hljs-string,\n    .hljs-template_tag,\n    .django .hljs-variable,\n    .smalltalk .hljs-class,\n    .hljs-addition,\n    .hljs-flow,\n    .hljs-stream,\n    .bash .hljs-variable,\n    .apache .hljs-tag,\n    .apache .hljs-cbracket,\n    .tex .hljs-command,\n    .tex .hljs-special,\n    .erlang_repl .hljs-function_or_atom,\n    .asciidoc .hljs-header,\n    .markdown .hljs-header,\n    .coffeescript .hljs-attribute {\n        color: #800;\n    }\n\n    .smartquote,\n    .hljs-comment,\n    .hljs-annotation,\n    .diff .hljs-header,\n    .hljs-chunk,\n    .asciidoc .hljs-blockquote,\n    .markdown .hljs-blockquote {\n        color: #888;\n    }\n\n    .hljs-number,\n    .hljs-date,\n    .hljs-regexp,\n    .hljs-literal,\n    .hljs-hexcolor,\n    .smalltalk .hljs-symbol,\n    .smalltalk .hljs-char,\n    .go .hljs-constant,\n    .hljs-change,\n    .lasso .hljs-variable,\n    .makefile .hljs-variable,\n    .asciidoc .hljs-bullet,\n    .markdown .hljs-bullet,\n    .asciidoc .hljs-link_url,\n    .markdown .hljs-link_url {\n        color: #080;\n    }\n\n    .hljs-label,\n    .hljs-javadoc,\n    .ruby .hljs-string,\n    .hljs-decorator,\n    .hljs-filter .hljs-argument,\n    .hljs-localvars,\n    .hljs-array,\n    .hljs-attr_selector,\n    .hljs-important,\n    .hljs-pseudo,\n    .hljs-pi,\n    .haml .hljs-bullet,\n    .hljs-doctype,\n    .hljs-deletion,\n    .hljs-envvar,\n    .hljs-shebang,\n    .apache .hljs-sqbracket,\n    .nginx .hljs-built_in,\n    .tex .hljs-formula,\n    .erlang_repl .hljs-reserved,\n    .hljs-prompt,\n    .asciidoc .hljs-link_label,\n    .markdown .hljs-link_label,\n    .vhdl .hljs-attribute,\n    .clojure .hljs-attribute,\n    .asciidoc .hljs-attribute,\n    .lasso .hljs-attribute,\n    .coffeescript .hljs-property,\n    .hljs-phony {\n        color: #88f;\n    }\n\n    .hljs-keyword,\n    .hljs-id,\n    .hljs-title,\n    .hljs-built_in,\n    .css .hljs-tag,\n    .hljs-javadoctag,\n    .hljs-phpdoc,\n    .hljs-dartdoc,\n    .hljs-yardoctag,\n    .smalltalk .hljs-class,\n    .hljs-winutils,\n    .bash .hljs-variable,\n    .apache .hljs-tag,\n    .hljs-type,\n    .hljs-typename,\n    .tex .hljs-command,\n    .asciidoc .hljs-strong,\n    .markdown .hljs-strong,\n    .hljs-request,\n    .hljs-status {\n        font-weight: bold;\n    }\n\n    .asciidoc .hljs-emphasis,\n    .markdown .hljs-emphasis {\n        font-style: italic;\n    }\n\n    .nginx .hljs-built_in {\n        font-weight: normal;\n    }\n\n    .coffeescript .javascript,\n    .javascript .xml,\n    .lasso .markup,\n    .tex .hljs-formula,\n    .xml .javascript,\n    .xml .vbscript,\n    .xml .css,\n    .xml .hljs-cdata {\n        opacity: 0.5;\n    }\n\n    #container {\n        padding: 15px;\n        margin-left: 20px;\n    }\n\n    pre {\n        border: 1px solid #ccc;\n        border-radius: 4px;\n        display: block;\n    }\n\n    pre code {\n        white-space: pre-wrap;\n    }\n\n    .hljs,\n    code {\n        font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;\n    }\n\n    pre {\n        background-color: #dddddd;\n        padding: 8px 0px 8px 30px;\n        word-wrap: break-word;\n    }\n\n    table tbody tr:nth-child(2n) {\n        background: rgba(158, 188, 226, 0.12);\n    }\n\n    :not(pre) > code {\n        padding: 2px 4px;\n        font-size: 90%;\n        color: #c7254e;\n        background-color: #f9f2f4;\n        white-space: nowrap;\n        border-radius: 4px;\n    }\n\n    th, td {\n        border: 1px solid #ccc;\n        padding: 6px 12px;\n    }\n\n    blockquote {\n        border-left-width: 10px;\n        background-color: rgba(102, 128, 153, 0.05);\n        border-top-right-radius: 5px;\n        border-bottom-right-radius: 5px;\n        padding: 1px 20px\n    }\n\n    blockquote.pull-right small:before, blockquote.pull-right .small:before {\n        content: ''\n    }\n\n    blockquote.pull-right small:after, blockquote.pull-right .small:after {\n        content: '\\00A0 \\2014'\n    }\n\n    blockquote:before, blockquote:after {\n        content: \"\"\n    }\n\n    blockquote {\n        margin: 0 0 1.1em\n    }\n\n    blockquote p {\n        margin-bottom: 1.1em;\n        font-size: 1em;\n        line-height: 1.45\n    }\n\n    blockquote ul:last-child, blockquote ol:last-child {\n        margin-bottom: 0\n    }\n\n    blockquote {\n        margin: 0 0 21px;\n        border-left: 10px solid #dddddd;\n    }</style>\n    <style type=\"text/css\" abt=\"234\"></style>\n    <input type=\"hidden\" id=\"_w_elixir\"></head>\n<body marginwidth=\"0\" marginheight=\"0\">\n<div id=\"container\"><h2 id=\"-\">接口名称</h2>\n    <h3 id=\"1-\">1) 请求地址</h3>\n    <blockquote>\n        <p><a href=\"https://tg-message.vercel.app/api\">https://tg-message.vercel.app/api</a>\n        </p>\n    </blockquote>\n    <h3 id=\"2-http-get\">2) 调用方式：HTTP get post</h3>\n    <h3 id=\"3-\">3) 接口描述：</h3>\n    <ul>\n        <li>TG版消息推送机器人,基于 vercel 函数搭建,免服务器</li>\n        <li>关注机器人 <a href=\"https://t.me/msg_sause_bot\">MessageBot</a></li>\n        <li>发送 <code>/token</code> 获取 token </li>\n        <li>Github: <a href=\"https://github.com/anhao/TgMessage\">https://github.com/anhao/TgMessage</a></li>\n        <li><a href=\"https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fanhao%2FTGMessage\"><img src=\"https://vercel.com/button\" alt=\"\"></a></li>\n    </ul>\n    <h3 id=\"4-\">4) 请求参数:</h3>\n    <table>\n        <thead>\n        <tr>\n            <th>字段名称</th>\n            <th style=\"text-align:center\">字段说明</th>\n            <th style=\"text-align:center\">类型</th>\n            <th style=\"text-align:center\">必填</th>\n            <th style=\"text-align:right\">备注</th>\n        </tr>\n        </thead>\n        <tbody>\n        <tr>\n            <td>token</td>\n            <td style=\"text-align:center\"></td>\n            <td style=\"text-align:center\">string</td>\n            <td style=\"text-align:center\">Y</td>\n            <td style=\"text-align:right\">token</td>\n        </tr>\n        <tr>\n            <td>message</td>\n            <td style=\"text-align:center\"></td>\n            <td style=\"text-align:center\">string</td>\n            <td style=\"text-align:center\">Y</td>\n            <td style=\"text-align:right\">要发送的消息内容</td>\n        </tr>\n        </tbody>\n    </table>\n    <h3 id=\"5-\">5) 请求返回结果:</h3>\n    <pre><code>{\"code\":200,\"message\":\"success\"}\n</code></pre>\n</div>\n</body>\n</html>"
  },
  {
    "path": "vercel.json",
    "content": "{\n  \"functions\": {\n    \"api/*.php\": {\n      \"runtime\": \"vercel-php@0.5.2\"\n    }\n  },\n  \"routes\": [\n    {\n      \"src\": \"/setWebHook\",\n      \"dest\": \"/api/setWebHook.php\"\n    },\n    {\n      \"src\": \"/webhook\",\n      \"dest\": \"/api/webhook.php\"\n    }\n  ]\n}\n"
  }
]