├── .github └── ISSUE_TEMPLATE │ ├── ----.yml │ └── --bug.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── GR_cookie.png ├── checkin_entrance.png ├── checkin_page.png ├── cookie.png ├── cookies.png ├── devtools.png ├── lib.png └── push_detail.png ├── checkin.py ├── config.py ├── requirements.txt └── sendNotify.py /.github/ISSUE_TEMPLATE/----.yml: -------------------------------------------------------------------------------- 1 | name: ✨功能请求 2 | description: 为这个项目提出一个想法,请先查看常见问题及搜索issue列表中有无你要提的问题 3 | title: "[Feature]: " 4 | body: 5 | - type: checkboxes 6 | id: check-answer 7 | attributes: 8 | label: 解决方案检查 9 | description: 请确保你已完成以下所有操作 10 | options: 11 | - label: 我已搜索issue列表(),但没有发现类似的问题 12 | required: true 13 | - type: textarea 14 | id: problem-description 15 | attributes: 16 | label: 问题描述 17 | description: 请添加清晰简洁的描述,说明你希望通过此功能请求解决的问题 18 | validations: 19 | required: true 20 | - type: textarea 21 | id: proposed-solution 22 | attributes: 23 | label: 描述你想要的解决方案 24 | description: 简洁明了地描述你要发生的事情 25 | validations: 26 | required: true 27 | - type: textarea 28 | id: additional-information 29 | attributes: 30 | label: 附加信息 31 | description: 如果你的问题需要进一步解释,或者想要表达其他内容,请在此处添加更多信息。(直接把图片、视频拖到编辑框即可添加图片或视频) 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--bug.yml: -------------------------------------------------------------------------------- 1 | name: 🐞报告Bug 2 | description: 报告bug,请先查看常见问题及搜索issue列表中有无你要提的问题 3 | title: "[Bug]: " 4 | body: 5 | - type: checkboxes 6 | id: check-answer 7 | attributes: 8 | label: 解决方案检查 9 | description: 请确保你已完成以下所有操作 10 | options: 11 | - label: 我已搜索issue列表(),并没有发现类似的问题 12 | required: true 13 | - type: input 14 | id: version 15 | attributes: 16 | label: 青龙版本 17 | description: 你使用什么版本的青龙? 18 | placeholder: "例如 2.10.13" 19 | validations: 20 | required: true 21 | - type: input 22 | id: operating-system-version 23 | attributes: 24 | label: 操作系统 25 | description: 您使用的是什么操作系统? 26 | placeholder: "例如 Ubuntu 20.04" 27 | validations: 28 | required: true 29 | - type: textarea 30 | id: vulnerability-feedback 31 | attributes: 32 | label: 问题反馈 33 | description: 对漏洞的内容简明描述 34 | validations: 35 | required: true 36 | - type: textarea 37 | id: additional-information 38 | attributes: 39 | label: 附加信息 40 | description: 如果你的问题需要进一步解释,或者想要表达其他内容,请在此处添加更多信息。(直接把图片、视频拖到编辑框即可添加图片或视频) 41 | 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | # GLaDOS 自动签到⚡ 5 | 6 | _✨ 基于 [Python](https://www.python.org/) 实现的[GLaDOS](https://github.com/glados-network/GLaDOS)签到程序 ✨_ 7 | 8 |
9 | 10 |

11 | 12 | license 13 | 14 | 15 | license 16 | 17 | 18 | license 19 | 20 |

21 | 22 | ## 项目特点 23 | 24 | - 基于 [Python](https://www.python.org/)语言 25 | - 可自定义签到时间(基于crontab) 26 | - 支持多账户 27 | - 支持本地部署 28 | - 支持部署在[青龙面板](https://github.com/whyour/qinglong) 29 | - 支持多种通知推送方式 30 | - [更新日志](#更新日志) 31 | 32 | ## 简单介绍一下GLaDOS 33 | 34 | >GLaDOS是一家高速稳定的V2Ray/Trojan机场,超过4年的老品牌,官方网站使用自主开发的管理系统,属于技术派的老站,支持WireGuard协议加速,而且流量套餐性价比非常高。 35 | 36 | GLaDOS家的优惠活动非常良心,新账号注册一段时间后基本都会赠送一次30天的基础套餐激活码,如果你的账户是教育版edu账户,甚至可以直接得到365天的基础套餐。不仅如此,每天签到也会获得一天当前套餐的续期,因此才有了本项目。 37 | 38 | [GLaDOS 项目地址](https://github.com/glados-network/GLaDOS) 39 | 40 | ## 开始使用 41 | 42 | ### 准备工作 43 |
44 | 账号的 cookie(并非仅此单一获取方式) 45 | 46 | 1. 注册 [GLaDos](https://glados.rocks/) 并登陆。 47 | (注册时可选填邀请码,双方都将获得微量的额外天数奖励。这一步并不重要,但我期待并感谢大家的支持) 48 | ``` 49 | 38JNV-P6O0T-XXC1F-CC3OI 50 | ``` 51 | 52 | 2. 在首页往下拉,找到 **我的会员 > 会员签到** 53 | 54 | ![checkin_entrance](assets/checkin_entrance.png) 55 | 56 | 3. 点击跳转到签到页面 57 | 58 | ![checkin_page](assets/checkin_page.png) 59 | 60 | 4. 打开 "开发者工具",通常快捷键为 **F12**,或是点击 **浏览器选项 > 更多工具 > 开发者工具**,打开后如图所示点击 "**network**" 标签 61 | 62 | ![devtools](assets/devtools.png) 63 | 64 | 5. 在签到页面点击签到,相对应的开发者工具 **network** 标签下会出现 "**checkin**" 请求,点击该请求,会出现更多信息,找到 "**Request Headers**" 里的 "**cookie**",接下来设置密钥时需要用到 65 | 66 | ![cookie](assets/cookie.png) 67 |
68 | 69 | ### qinglong 部署 (推荐) 70 | 71 |
72 | 一、安装依赖 73 | 74 | - 打开青龙面板,依赖管理页面。切换到Python3模块,点击新建依赖,导入并安装依赖 75 | ``` 76 | requests 77 | ``` 78 | 79 | ![cookie](assets/lib.png) 80 | 81 |
82 | 83 |
84 | 二、在青龙面板中设置环境变量 85 | 86 | - 名称填入 **GR_COOKIE**, 值填入准备工作中账户的COOKIE。注:COOKIE需按 **'koa:sess=xxxxxxxxx; koa:sess.sig=xxxx;'** 的格式填入 87 | - 多账号多次添加变量 88 | 89 | ![cookie](assets/GR_cookie.png) 90 | 91 |
92 | 93 |
94 | 三、在青龙中拉取本仓库 95 | 96 | - 国内环境拉取指令(带代理) 97 | ``` 98 | ql repo https://ghproxy.com/https://github.com/hennessey-v/GlaDOS_Checkin_ql.git "checkin.py" "backUp|assets|README.md" "sendNotify.py" 99 | ``` 100 | - 国外环境拉取指令 101 | ``` 102 | ql repo https://github.com/hennessey-v/GlaDOS_Checkin_ql.git "checkin.py" "backUp|assets|README.md" "sendNotify.py" 103 | ``` 104 |
105 | 106 |
107 | 四、运行脚本查看运行结果 108 | 109 | ![cookie](assets/push_detail.png) 110 | 111 |
112 | 113 | ### 本机部署 114 | 115 |
116 | 一、拉取仓库到本地 117 | 118 | - 国内环境拉取指令(带代理) 119 | ``` 120 | git clone https://ghproxy.com/https://github.com/hennessey-v/GlaDOS_Checkin_ql.git GlaDOS_Checkin 121 | ``` 122 | - 国外环境拉取指令 123 | ``` 124 | git clone https://github.com/hennessey-v/GlaDOS_Checkin_ql.git GlaDOS_Checkin 125 | ``` 126 |
127 | 128 |
129 | 二、安装依赖 130 | 131 | - 进入项目目录输入以下命令 132 | - 国内环境 133 | ``` 134 | pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple 135 | ``` 136 | - 国外环境 137 | ``` 138 | pip install -r requirements.txt 139 | ``` 140 |
141 | 142 |
143 | 三、配置cookie 144 | 145 | - 进入 GlaDOS_Checkin 文件夹,将cookie按照 **'koa:sess=xxxxxxxxx; koa:sess.sig=xxxx;'** 的格式填入 **config.py** ,多账号用 "," 分割 146 | ![cookie](assets/cookies.png) 147 |
148 |
149 | 四、运行脚本 150 | 151 | - 在GlaDOS_Checkin目录下,运行脚本 152 | ``` 153 | python checkin.py 154 | ``` 155 | 156 | - linux可配和[crontab](https://www.runoob.com/linux/linux-comm-crontab.html)实现定时签到,windows可使用[go-crontab](https://github.com/hezhizheng/go-crontab/releases)来实现。具体用法请自行探索 157 | 158 |
159 | 160 | 161 | 162 | ## 更新日志 163 |
164 | 更新日志 165 | 166 | ### [1.2.4] - 2023-7.27 167 | #### 变更 168 | - 修复签到失败的问题 169 | 170 | ### [1.2.3] - 2023-7.26 171 | #### 变更 172 | - 文档增加安装依赖步骤 173 | 174 | ### [1.2.2] - 2023-7.21 175 | #### 新增 176 | - 新增飞书等多种通知方式 177 | 178 | ### [1.2.1] - 2023-5-7 179 | #### 新增 180 | - 新增本地部署 181 | - 新增运行失败提示 182 | #### 变更 183 | - 优化运行中信息显示效果 184 | - 完善文档 185 | 186 | ### [1.2.0] - 2023-03-22 187 | #### 变更 188 | - 优化逻辑,增强运行稳定性。 189 | - 修复了空Cookie导致的报错。 190 | - 完善注释,增强可读性。 191 | 192 | ### [1.1.2] - 2023-02-17 193 | #### 变更 194 | - 修复企业微信应用文本方式推送错误(感谢[肥牛(sailcom)](https://github.com/sailcom)) 195 | - 文档小变化 196 | 197 | ### [1.1.1] - 2023-01-31 198 | #### 新增 199 | - 添加了国内环境下的拉取指令 200 | - 新增问题模板 201 | 202 | ### [1.1.0] - 2023-01-29 203 | #### 变更 204 | - 修复拉取脚本无法自动添加任务的问题 205 | - 文档更新 206 | 207 | ### [1.0.0] - 2023-01-12 208 | 项目发布 209 | #### 变更 210 | - 兼容多账户,推送信息增加账户邮箱信息提示 211 | #### 新增 212 | - 多账号签到 213 | - 多种推送渠道 214 | - Bark服务 215 | - TGBot推送 216 | - QQ机器人 217 | - 企业微信应用 218 | - 企业微信BOT 219 | - 微信推送Plus+ 220 | 221 |
222 | 223 | ## 鸣谢 224 | - 部分程序代码来源于开源项目[glados_checkin](https://github.com/akinlau/glados_checkin),部分图片素材来自于[DullSword](https://github.com/DullSword)大佬 225 | - 问题模板灵感来自于开源项目[lx-music-desktop](https://github.com/lyswhut/lx-music-desktop) 226 | 227 | 228 | ## Star⭐ 229 | 230 | **如果你觉得这个项目还不错的话,可以支持一下点个 Star⭐.** 231 | -------------------------------------------------------------------------------- /assets/GR_cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/GR_cookie.png -------------------------------------------------------------------------------- /assets/checkin_entrance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/checkin_entrance.png -------------------------------------------------------------------------------- /assets/checkin_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/checkin_page.png -------------------------------------------------------------------------------- /assets/cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/cookie.png -------------------------------------------------------------------------------- /assets/cookies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/cookies.png -------------------------------------------------------------------------------- /assets/devtools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/devtools.png -------------------------------------------------------------------------------- /assets/lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/lib.png -------------------------------------------------------------------------------- /assets/push_detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaineaAN/GlaDOS_Checkin_ql/d858874736fc8d80f24ebcd17721fd1f924252db/assets/push_detail.png -------------------------------------------------------------------------------- /checkin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | File: checkin.py(GLaDOS签到) 6 | Author: Hennessey 7 | cron: 40 0 * * * 8 | new Env('GLaDOS签到'); 9 | Update: 2023/7/27 10 | """ 11 | 12 | 13 | import requests 14 | import json 15 | import os 16 | import sys 17 | import time 18 | 19 | # 获取GlaDOS账号Cookie 20 | def get_cookies(): 21 | if os.environ.get("GR_COOKIE"): 22 | print("已获取并使用Env环境 Cookie") 23 | if '&' in os.environ["GR_COOKIE"]: 24 | cookies = os.environ["GR_COOKIE"].split('&') 25 | elif '\n' in os.environ["GR_COOKIE"]: 26 | cookies = os.environ["GR_COOKIE"].split('\n') 27 | else: 28 | cookies = [os.environ["GR_COOKIE"]] 29 | else: 30 | from config import Cookies 31 | cookies = Cookies 32 | if len(cookies) == 0: 33 | print("未获取到正确的GlaDOS账号Cookie") 34 | return 35 | print(f"共获取到{len(cookies)}个GlaDOS账号Cookie\n") 36 | print(f"脚本执行时间(北京时区): {time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())}\n") 37 | return cookies 38 | 39 | 40 | # 加载通知服务 41 | def load_send(): 42 | cur_path = os.path.abspath(os.path.dirname(__file__)) 43 | sys.path.append(cur_path) 44 | if os.path.exists(cur_path + "/sendNotify.py"): 45 | try: 46 | from sendNotify import send 47 | return send 48 | except Exception as e: 49 | print(f"加载通知服务失败:{e}") 50 | return None 51 | else: 52 | print("加载通知服务失败") 53 | return None 54 | 55 | 56 | # GlaDOS签到 57 | def checkin(cookie): 58 | checkin_url= "https://glados.rocks/api/user/checkin" 59 | state_url= "https://glados.rocks/api/user/status" 60 | referer = 'https://glados.rocks/console/checkin' 61 | origin = "https://glados.rocks" 62 | useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" 63 | payload={ 64 | 'token': 'glados.one' 65 | } 66 | try: 67 | checkin = requests.post(checkin_url,headers={ 68 | 'cookie': cookie , 69 | 'referer': referer, 70 | 'origin':origin, 71 | 'user-agent':useragent, 72 | 'content-type':'application/json;charset=UTF-8'},data=json.dumps(payload)) 73 | state = requests.get(state_url,headers={ 74 | 'cookie': cookie , 75 | 'referer': referer, 76 | 'origin':origin, 77 | 'user-agent':useragent}) 78 | except Exception as e: 79 | print(f"签到失败,请检查网络:{e}") 80 | return None, None, None 81 | 82 | try: 83 | mess = checkin.json()['message'] 84 | mail = state.json()['data']['email'] 85 | time = state.json()['data']['leftDays'].split('.')[0] 86 | except Exception as e: 87 | print(f"解析登录结果失败:{e}") 88 | return None, None, None 89 | 90 | return mess, time, mail 91 | 92 | 93 | # 执行签到任务 94 | def run_checkin(): 95 | contents = [] 96 | cookies = get_cookies() 97 | if not cookies: 98 | return "" 99 | 100 | for cookie in cookies: 101 | ret, remain, email = checkin(cookie) 102 | if not ret: 103 | continue 104 | 105 | content = f"账号:{email}\n签到结果:{ret}\n剩余天数:{remain}\n" 106 | print(content) 107 | contents.append(content) 108 | 109 | contents_str = "".join(contents) 110 | return contents_str 111 | 112 | 113 | if __name__ == '__main__': 114 | title = "GlaDOS签到通知" 115 | contents = run_checkin() 116 | send_notify = load_send() 117 | if send_notify: 118 | if contents =='': 119 | contents=f'签到失败,请检查账户信息以及网络环境' 120 | print(contents) 121 | send_notify(title, contents) -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | Cookies = [ 2 | #'koa:sess=XXXXXXXXXXXXXXXXXXXX; koa:sess.sig=XXXXXXXXXX;', #cookie1 3 | #'koa:sess=XXXXXXXXXXXXXXXXXXXX; koa:sess.sig=XXXXXXXXXX;', #cookie2 4 | ] -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.31.0 2 | -------------------------------------------------------------------------------- /sendNotify.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # _*_ coding:utf-8 _*_ 3 | import base64 4 | import hashlib 5 | import hmac 6 | import json 7 | import os 8 | import re 9 | import threading 10 | import time 11 | import urllib.parse 12 | import smtplib 13 | from email.mime.text import MIMEText 14 | from email.header import Header 15 | from email.utils import formataddr 16 | 17 | import requests 18 | 19 | # 原先的 print 函数和主线程的锁 20 | _print = print 21 | mutex = threading.Lock() 22 | 23 | 24 | # 定义新的 print 函数 25 | def print(text, *args, **kw): 26 | """ 27 | 使输出有序进行,不出现多线程同一时间输出导致错乱的问题。 28 | """ 29 | with mutex: 30 | _print(text, *args, **kw) 31 | 32 | 33 | # 通知服务 34 | # fmt: off 35 | push_config = { 36 | 'HITOKOTO': False, # 启用一言(随机句子) 37 | 38 | 'BARK_PUSH': '', # bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/ 39 | 'BARK_ARCHIVE': '', # bark 推送是否存档 40 | 'BARK_GROUP': '', # bark 推送分组 41 | 'BARK_SOUND': '', # bark 推送声音 42 | 'BARK_ICON': '', # bark 推送图标 43 | 44 | 'CONSOLE': True, # 控制台输出 45 | 46 | 'DD_BOT_SECRET': '', # 钉钉机器人的 DD_BOT_SECRET 47 | 'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN 48 | 49 | 'FSKEY': '', # 飞书机器人的 FSKEY 50 | 51 | 'GOBOT_URL': '', # go-cqhttp 52 | # 推送到个人QQ:http://127.0.0.1/send_private_msg 53 | # 群:http://127.0.0.1/send_group_msg 54 | 'GOBOT_QQ': '', # go-cqhttp 的推送群或用户 55 | # GOBOT_URL 设置 /send_private_msg 时填入 user_id=个人QQ 56 | # /send_group_msg 时填入 group_id=QQ群 57 | 'GOBOT_TOKEN': '', # go-cqhttp 的 access_token 58 | 59 | 'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080 60 | 'GOTIFY_TOKEN': '', # gotify的消息应用token 61 | 'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0 62 | 63 | 'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY 64 | 65 | 'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版 66 | 67 | 'DEER_KEY': '', # PushDeer 的 PUSHDEER_KEY 68 | 'DEER_URL': '', # PushDeer 的 PUSHDEER_URL 69 | 70 | 'CHAT_URL': '', # synology chat url 71 | 'CHAT_TOKEN': '', # synology chat token 72 | 73 | 'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌 74 | 'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码 75 | 76 | 'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY 77 | 'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE 78 | 79 | 'QYWX_AM': '', # 企业微信应用 80 | 81 | 'QYWX_KEY': '', # 企业微信机器人 82 | 83 | 'TG_BOT_TOKEN': '', # tg 机器人的 TG_BOT_TOKEN,例:1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ 84 | 'TG_USER_ID': '', # tg 机器人的 TG_USER_ID,例:1434078534 85 | 'TG_API_HOST': '', # tg 代理 api 86 | 'TG_PROXY_AUTH': '', # tg 代理认证参数 87 | 'TG_PROXY_HOST': '', # tg 机器人的 TG_PROXY_HOST 88 | 'TG_PROXY_PORT': '', # tg 机器人的 TG_PROXY_PORT 89 | 90 | 'AIBOTK_KEY': '', # 智能微秘书 个人中心的apikey 文档地址:http://wechat.aibotk.com/docs/about 91 | 'AIBOTK_TYPE': '', # 智能微秘书 发送目标 room 或 contact 92 | 'AIBOTK_NAME': '', # 智能微秘书 发送群名 或者好友昵称和type要对应好 93 | 94 | 'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465 95 | 'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false 96 | 'SMTP_EMAIL': '', # SMTP 收发件邮箱,通知将会由自己发给自己 97 | 'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定 98 | 'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写 99 | } 100 | notify_function = [] 101 | # fmt: on 102 | 103 | # 首先读取 面板变量 或者 github action 运行变量 104 | for k in push_config: 105 | if os.getenv(k): 106 | v = os.getenv(k) 107 | push_config[k] = v 108 | 109 | 110 | def bark(title: str, content: str) -> None: 111 | """ 112 | 使用 bark 推送消息。 113 | """ 114 | if not push_config.get("BARK_PUSH"): 115 | print("bark 服务的 BARK_PUSH 未设置!!\n取消推送") 116 | return 117 | print("bark 服务启动") 118 | 119 | if push_config.get("BARK_PUSH").startswith("http"): 120 | url = f'{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}' 121 | else: 122 | url = f'https://api.day.app/{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}' 123 | 124 | bark_params = { 125 | "BARK_ARCHIVE": "isArchive", 126 | "BARK_GROUP": "group", 127 | "BARK_SOUND": "sound", 128 | "BARK_ICON": "icon", 129 | } 130 | params = "" 131 | for pair in filter( 132 | lambda pairs: pairs[0].startswith("BARK_") 133 | and pairs[0] != "BARK_PUSH" 134 | and pairs[1] 135 | and bark_params.get(pairs[0]), 136 | push_config.items(), 137 | ): 138 | params += f"{bark_params.get(pair[0])}={pair[1]}&" 139 | if params: 140 | url = url + "?" + params.rstrip("&") 141 | response = requests.get(url).json() 142 | 143 | if response["code"] == 200: 144 | print("bark 推送成功!") 145 | else: 146 | print("bark 推送失败!") 147 | 148 | 149 | def console(title: str, content: str) -> None: 150 | """ 151 | 使用 控制台 推送消息。 152 | """ 153 | print(f"{title}\n\n{content}") 154 | 155 | 156 | def dingding_bot(title: str, content: str) -> None: 157 | """ 158 | 使用 钉钉机器人 推送消息。 159 | """ 160 | if not push_config.get("DD_BOT_SECRET") or not push_config.get("DD_BOT_TOKEN"): 161 | print("钉钉机器人 服务的 DD_BOT_SECRET 或者 DD_BOT_TOKEN 未设置!!\n取消推送") 162 | return 163 | print("钉钉机器人 服务启动") 164 | 165 | timestamp = str(round(time.time() * 1000)) 166 | secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8") 167 | string_to_sign = "{}\n{}".format( 168 | timestamp, push_config.get("DD_BOT_SECRET")) 169 | string_to_sign_enc = string_to_sign.encode("utf-8") 170 | hmac_code = hmac.new( 171 | secret_enc, string_to_sign_enc, digestmod=hashlib.sha256 172 | ).digest() 173 | sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) 174 | url = f'https://oapi.dingtalk.com/robot/send?access_token={push_config.get("DD_BOT_TOKEN")}×tamp={timestamp}&sign={sign}' 175 | headers = {"Content-Type": "application/json;charset=utf-8"} 176 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}} 177 | response = requests.post( 178 | url=url, data=json.dumps(data), headers=headers, timeout=15 179 | ).json() 180 | 181 | if not response["errcode"]: 182 | print("钉钉机器人 推送成功!") 183 | else: 184 | print("钉钉机器人 推送失败!") 185 | 186 | 187 | def feishu_bot(title: str, content: str) -> None: 188 | """ 189 | 使用 飞书机器人 推送消息。 190 | """ 191 | if not push_config.get("FSKEY"): 192 | print("飞书 服务的 FSKEY 未设置!!\n取消推送") 193 | return 194 | print("飞书 服务启动") 195 | 196 | url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}' 197 | data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}} 198 | response = requests.post(url, data=json.dumps(data)).json() 199 | 200 | if response.get("StatusCode") == 0: 201 | print("飞书 推送成功!") 202 | else: 203 | print("飞书 推送失败!错误信息如下:\n", response) 204 | 205 | 206 | def go_cqhttp(title: str, content: str) -> None: 207 | """ 208 | 使用 go_cqhttp 推送消息。 209 | """ 210 | if not push_config.get("GOBOT_URL") or not push_config.get("GOBOT_QQ"): 211 | print("go-cqhttp 服务的 GOBOT_URL 或 GOBOT_QQ 未设置!!\n取消推送") 212 | return 213 | print("go-cqhttp 服务启动") 214 | 215 | url = f'{push_config.get("GOBOT_URL")}?access_token={push_config.get("GOBOT_TOKEN")}&{push_config.get("GOBOT_QQ")}&message=标题:{title}\n内容:{content}' 216 | response = requests.get(url).json() 217 | 218 | if response["status"] == "ok": 219 | print("go-cqhttp 推送成功!") 220 | else: 221 | print("go-cqhttp 推送失败!") 222 | 223 | 224 | def gotify(title: str, content: str) -> None: 225 | """ 226 | 使用 gotify 推送消息。 227 | """ 228 | if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"): 229 | print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送") 230 | return 231 | print("gotify 服务启动") 232 | 233 | url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}' 234 | data = {"title": title, "message": content, 235 | "priority": push_config.get("GOTIFY_PRIORITY")} 236 | response = requests.post(url, data=data).json() 237 | 238 | if response.get("id"): 239 | print("gotify 推送成功!") 240 | else: 241 | print("gotify 推送失败!") 242 | 243 | 244 | def iGot(title: str, content: str) -> None: 245 | """ 246 | 使用 iGot 推送消息。 247 | """ 248 | if not push_config.get("IGOT_PUSH_KEY"): 249 | print("iGot 服务的 IGOT_PUSH_KEY 未设置!!\n取消推送") 250 | return 251 | print("iGot 服务启动") 252 | 253 | url = f'https://push.hellyw.com/{push_config.get("IGOT_PUSH_KEY")}' 254 | data = {"title": title, "content": content} 255 | headers = {"Content-Type": "application/x-www-form-urlencoded"} 256 | response = requests.post(url, data=data, headers=headers).json() 257 | 258 | if response["ret"] == 0: 259 | print("iGot 推送成功!") 260 | else: 261 | print(f'iGot 推送失败!{response["errMsg"]}') 262 | 263 | 264 | def serverJ(title: str, content: str) -> None: 265 | """ 266 | 通过 serverJ 推送消息。 267 | """ 268 | if not push_config.get("PUSH_KEY"): 269 | print("serverJ 服务的 PUSH_KEY 未设置!!\n取消推送") 270 | return 271 | print("serverJ 服务启动") 272 | 273 | data = {"text": title, "desp": content.replace("\n", "\n\n")} 274 | if push_config.get("PUSH_KEY").find("SCT") != -1: 275 | url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send' 276 | else: 277 | url = f'https://sc.ftqq.com/{push_config.get("PUSH_KEY")}.send' 278 | response = requests.post(url, data=data).json() 279 | 280 | if response.get("errno") == 0 or response.get("code") == 0: 281 | print("serverJ 推送成功!") 282 | else: 283 | print(f'serverJ 推送失败!错误码:{response["message"]}') 284 | 285 | 286 | def pushdeer(title: str, content: str) -> None: 287 | """ 288 | 通过PushDeer 推送消息 289 | """ 290 | if not push_config.get("DEER_KEY"): 291 | print("PushDeer 服务的 DEER_KEY 未设置!!\n取消推送") 292 | return 293 | print("PushDeer 服务启动") 294 | data = {"text": title, "desp": content, "type": "markdown", 295 | "pushkey": push_config.get("DEER_KEY")} 296 | url = 'https://api2.pushdeer.com/message/push' 297 | if push_config.get("DEER_URL"): 298 | url = push_config.get("DEER_URL") 299 | 300 | response = requests.post(url, data=data).json() 301 | 302 | if len(response.get("content").get("result")) > 0: 303 | print("PushDeer 推送成功!") 304 | else: 305 | print("PushDeer 推送失败!错误信息:", response) 306 | 307 | 308 | def chat(title: str, content: str) -> None: 309 | """ 310 | 通过Chat 推送消息 311 | """ 312 | if not push_config.get("CHAT_URL") or not push_config.get("CHAT_TOKEN"): 313 | print("chat 服务的 CHAT_URL或CHAT_TOKEN 未设置!!\n取消推送") 314 | return 315 | print("chat 服务启动") 316 | data = 'payload=' + json.dumps({'text': title + '\n' + content}) 317 | url = push_config.get("CHAT_URL") + push_config.get("CHAT_TOKEN") 318 | response = requests.post(url, data=data) 319 | 320 | if response.status_code == 200: 321 | print("Chat 推送成功!") 322 | else: 323 | print("Chat 推送失败!错误信息:", response) 324 | 325 | 326 | def pushplus_bot(title: str, content: str) -> None: 327 | """ 328 | 通过 push+ 推送消息。 329 | """ 330 | if not push_config.get("PUSH_PLUS_TOKEN"): 331 | print("PUSHPLUS 服务的 PUSH_PLUS_TOKEN 未设置!!\n取消推送") 332 | return 333 | print("PUSHPLUS 服务启动") 334 | 335 | url = "http://www.pushplus.plus/send" 336 | data = { 337 | "token": push_config.get("PUSH_PLUS_TOKEN"), 338 | "title": title, 339 | "content": content, 340 | "topic": push_config.get("PUSH_PLUS_USER"), 341 | } 342 | body = json.dumps(data).encode(encoding="utf-8") 343 | headers = {"Content-Type": "application/json"} 344 | response = requests.post(url=url, data=body, headers=headers).json() 345 | 346 | if response["code"] == 200: 347 | print("PUSHPLUS 推送成功!") 348 | 349 | else: 350 | 351 | url_old = "http://pushplus.hxtrip.com/send" 352 | headers["Accept"] = "application/json" 353 | response = requests.post( 354 | url=url_old, data=body, headers=headers).json() 355 | 356 | if response["code"] == 200: 357 | print("PUSHPLUS(hxtrip) 推送成功!") 358 | 359 | else: 360 | print("PUSHPLUS 推送失败!") 361 | 362 | 363 | def qmsg_bot(title: str, content: str) -> None: 364 | """ 365 | 使用 qmsg 推送消息。 366 | """ 367 | if not push_config.get("QMSG_KEY") or not push_config.get("QMSG_TYPE"): 368 | print("qmsg 的 QMSG_KEY 或者 QMSG_TYPE 未设置!!\n取消推送") 369 | return 370 | print("qmsg 服务启动") 371 | 372 | url = f'https://qmsg.zendee.cn/{push_config.get("QMSG_TYPE")}/{push_config.get("QMSG_KEY")}' 373 | payload = { 374 | "msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")} 375 | response = requests.post(url=url, params=payload).json() 376 | 377 | if response["code"] == 0: 378 | print("qmsg 推送成功!") 379 | else: 380 | print(f'qmsg 推送失败!{response["reason"]}') 381 | 382 | 383 | def wecom_app(title: str, content: str) -> None: 384 | """ 385 | 通过 企业微信 APP 推送消息。 386 | """ 387 | if not push_config.get("QYWX_AM"): 388 | print("QYWX_AM 未设置!!\n取消推送") 389 | return 390 | QYWX_AM_AY = re.split(",", push_config.get("QYWX_AM")) 391 | if 4 < len(QYWX_AM_AY) > 5: 392 | print("QYWX_AM 设置错误!!\n取消推送") 393 | return 394 | print("企业微信 APP 服务启动") 395 | 396 | corpid = QYWX_AM_AY[0] 397 | corpsecret = QYWX_AM_AY[1] 398 | touser = QYWX_AM_AY[2] 399 | agentid = QYWX_AM_AY[3] 400 | try: 401 | media_id = QYWX_AM_AY[4] 402 | except IndexError: 403 | media_id = "" 404 | wx = WeCom(corpid, corpsecret, agentid) 405 | # 如果没有配置 media_id 默认就以 text 方式发送 406 | if not media_id: 407 | message = title + "\n\n" + content 408 | response = wx.send_text(message, touser) 409 | else: 410 | response = wx.send_mpnews(title, content, media_id, touser) 411 | 412 | if response == "ok": 413 | print("企业微信推送成功!") 414 | else: 415 | print("企业微信推送失败!错误信息如下:\n", response) 416 | 417 | 418 | class WeCom: 419 | def __init__(self, corpid, corpsecret, agentid): 420 | self.CORPID = corpid 421 | self.CORPSECRET = corpsecret 422 | self.AGENTID = agentid 423 | 424 | def get_access_token(self): 425 | url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken" 426 | values = { 427 | "corpid": self.CORPID, 428 | "corpsecret": self.CORPSECRET, 429 | } 430 | req = requests.post(url, params=values) 431 | data = json.loads(req.text) 432 | return data["access_token"] 433 | 434 | def send_text(self, message, touser="@all"): 435 | send_url = ( 436 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" 437 | + self.get_access_token() 438 | ) 439 | send_values = { 440 | "touser": touser, 441 | "msgtype": "text", 442 | "agentid": self.AGENTID, 443 | "text": {"content": message}, 444 | "safe": "0", 445 | } 446 | send_msges = bytes(json.dumps(send_values), "utf-8") 447 | respone = requests.post(send_url, send_msges) 448 | respone = respone.json() 449 | return respone["errmsg"] 450 | 451 | def send_mpnews(self, title, message, media_id, touser="@all"): 452 | send_url = ( 453 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" 454 | + self.get_access_token() 455 | ) 456 | send_values = { 457 | "touser": touser, 458 | "msgtype": "mpnews", 459 | "agentid": self.AGENTID, 460 | "mpnews": { 461 | "articles": [ 462 | { 463 | "title": title, 464 | "thumb_media_id": media_id, 465 | "author": "Author", 466 | "content_source_url": "", 467 | "content": message.replace("\n", "
"), 468 | "digest": message, 469 | } 470 | ] 471 | }, 472 | } 473 | send_msges = bytes(json.dumps(send_values), "utf-8") 474 | respone = requests.post(send_url, send_msges) 475 | respone = respone.json() 476 | return respone["errmsg"] 477 | 478 | 479 | def wecom_bot(title: str, content: str) -> None: 480 | """ 481 | 通过 企业微信机器人 推送消息。 482 | """ 483 | if not push_config.get("QYWX_KEY"): 484 | print("企业微信机器人 服务的 QYWX_KEY 未设置!!\n取消推送") 485 | return 486 | print("企业微信机器人服务启动") 487 | 488 | url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}" 489 | headers = {"Content-Type": "application/json;charset=utf-8"} 490 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}} 491 | response = requests.post( 492 | url=url, data=json.dumps(data), headers=headers, timeout=15 493 | ).json() 494 | 495 | if response["errcode"] == 0: 496 | print("企业微信机器人推送成功!") 497 | else: 498 | print("企业微信机器人推送失败!") 499 | 500 | 501 | def telegram_bot(title: str, content: str) -> None: 502 | """ 503 | 使用 telegram 机器人 推送消息。 504 | """ 505 | if not push_config.get("TG_BOT_TOKEN") or not push_config.get("TG_USER_ID"): 506 | print("tg 服务的 bot_token 或者 user_id 未设置!!\n取消推送") 507 | return 508 | print("tg 服务启动") 509 | 510 | if push_config.get("TG_API_HOST"): 511 | url = f"https://{push_config.get('TG_API_HOST')}/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage" 512 | else: 513 | url = ( 514 | f"https://api.telegram.org/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage" 515 | ) 516 | headers = {"Content-Type": "application/x-www-form-urlencoded"} 517 | payload = { 518 | "chat_id": str(push_config.get("TG_USER_ID")), 519 | "text": f"{title}\n\n{content}", 520 | "disable_web_page_preview": "true", 521 | } 522 | proxies = None 523 | if push_config.get("TG_PROXY_HOST") and push_config.get("TG_PROXY_PORT"): 524 | if push_config.get("TG_PROXY_AUTH") is not None and "@" not in push_config.get( 525 | "TG_PROXY_HOST" 526 | ): 527 | push_config["TG_PROXY_HOST"] = ( 528 | push_config.get("TG_PROXY_AUTH") 529 | + "@" 530 | + push_config.get("TG_PROXY_HOST") 531 | ) 532 | proxyStr = "http://{}:{}".format( 533 | push_config.get("TG_PROXY_HOST"), push_config.get("TG_PROXY_PORT") 534 | ) 535 | proxies = {"http": proxyStr, "https": proxyStr} 536 | response = requests.post( 537 | url=url, headers=headers, params=payload, proxies=proxies 538 | ).json() 539 | 540 | if response["ok"]: 541 | print("tg 推送成功!") 542 | else: 543 | print("tg 推送失败!") 544 | 545 | 546 | def aibotk(title: str, content: str) -> None: 547 | """ 548 | 使用 智能微秘书 推送消息。 549 | """ 550 | if not push_config.get("AIBOTK_KEY") or not push_config.get("AIBOTK_TYPE") or not push_config.get("AIBOTK_NAME"): 551 | print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送") 552 | return 553 | print("智能微秘书 服务启动") 554 | 555 | if push_config.get("AIBOTK_TYPE") == 'room': 556 | url = "https://api-bot.aibotk.com/openapi/v1/chat/room" 557 | data = { 558 | "apiKey": push_config.get("AIBOTK_KEY"), 559 | "roomName": push_config.get("AIBOTK_NAME"), 560 | "message": {"type": 1, "content": f'【青龙快讯】\n\n{title}\n{content}'} 561 | } 562 | else: 563 | url = "https://api-bot.aibotk.com/openapi/v1/chat/contact" 564 | data = { 565 | "apiKey": push_config.get("AIBOTK_KEY"), 566 | "name": push_config.get("AIBOTK_NAME"), 567 | "message": {"type": 1, "content": f'【青龙快讯】\n\n{title}\n{content}'} 568 | } 569 | body = json.dumps(data).encode(encoding="utf-8") 570 | headers = {"Content-Type": "application/json"} 571 | response = requests.post(url=url, data=body, headers=headers).json() 572 | print(response) 573 | if response["code"] == 0: 574 | print("智能微秘书 推送成功!") 575 | else: 576 | print(f'智能微秘书 推送失败!{response["error"]}') 577 | 578 | 579 | def smtp(title: str, content: str) -> None: 580 | """ 581 | 使用 SMTP 邮件 推送消息。 582 | """ 583 | if not push_config.get("SMTP_SERVER") or not push_config.get("SMTP_SSL") or not push_config.get("SMTP_EMAIL") or not push_config.get("SMTP_PASSWORD") or not push_config.get("SMTP_NAME"): 584 | print("SMTP 邮件 的 SMTP_SERVER 或者 SMTP_SSL 或者 SMTP_EMAIL 或者 SMTP_PASSWORD 或者 SMTP_NAME 未设置!!\n取消推送") 585 | return 586 | print("SMTP 邮件 服务启动") 587 | 588 | message = MIMEText(content, 'plain', 'utf-8') 589 | message['From'] = formataddr((Header(push_config.get( 590 | "SMTP_NAME"), 'utf-8').encode(), push_config.get("SMTP_EMAIL"))) 591 | message['To'] = formataddr((Header(push_config.get( 592 | "SMTP_NAME"), 'utf-8').encode(), push_config.get("SMTP_EMAIL"))) 593 | message['Subject'] = Header(title, 'utf-8') 594 | 595 | try: 596 | smtp_server = smtplib.SMTP_SSL(push_config.get("SMTP_SERVER")) if push_config.get( 597 | "SMTP_SSL") == 'true' else smtplib.SMTP(push_config.get("SMTP_SERVER")) 598 | smtp_server.login(push_config.get("SMTP_EMAIL"), 599 | push_config.get("SMTP_PASSWORD")) 600 | smtp_server.sendmail(push_config.get("SMTP_EMAIL"), 601 | push_config.get("SMTP_EMAIL"), message.as_bytes()) 602 | smtp_server.close() 603 | print("SMTP 邮件 推送成功!") 604 | except Exception as e: 605 | print(f'SMTP 邮件 推送失败!{e}') 606 | 607 | 608 | def one() -> str: 609 | """ 610 | 获取一条一言。 611 | :return: 612 | """ 613 | url = "https://v1.hitokoto.cn/" 614 | res = requests.get(url).json() 615 | return res["hitokoto"] + " ----" + res["from"] 616 | 617 | 618 | if push_config.get("BARK_PUSH"): 619 | notify_function.append(bark) 620 | if push_config.get("CONSOLE"): 621 | notify_function.append(console) 622 | if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"): 623 | notify_function.append(dingding_bot) 624 | if push_config.get("FSKEY"): 625 | notify_function.append(feishu_bot) 626 | if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"): 627 | notify_function.append(go_cqhttp) 628 | if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"): 629 | notify_function.append(gotify) 630 | if push_config.get("IGOT_PUSH_KEY"): 631 | notify_function.append(iGot) 632 | if push_config.get("PUSH_KEY"): 633 | notify_function.append(serverJ) 634 | if push_config.get("DEER_KEY"): 635 | notify_function.append(pushdeer) 636 | if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"): 637 | notify_function.append(chat) 638 | if push_config.get("PUSH_PLUS_TOKEN"): 639 | notify_function.append(pushplus_bot) 640 | if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"): 641 | notify_function.append(qmsg_bot) 642 | if push_config.get("QYWX_AM"): 643 | notify_function.append(wecom_app) 644 | if push_config.get("QYWX_KEY"): 645 | notify_function.append(wecom_bot) 646 | if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"): 647 | notify_function.append(telegram_bot) 648 | if push_config.get("AIBOTK_KEY") and push_config.get("AIBOTK_TYPE") and push_config.get("AIBOTK_NAME"): 649 | notify_function.append(aibotk) 650 | if push_config.get("SMTP_SERVER") and push_config.get("SMTP_SSL") and push_config.get("SMTP_EMAIL") and push_config.get("SMTP_PASSWORD") and push_config.get("SMTP_NAME"): 651 | notify_function.append(smtp) 652 | 653 | 654 | def send(title: str, content: str) -> None: 655 | if not content: 656 | print(f"{title} 推送内容为空!") 657 | return 658 | 659 | # 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔 660 | skipTitle = os.getenv("SKIP_PUSH_TITLE") 661 | if skipTitle: 662 | if (title in re.split("\n", skipTitle)): 663 | print(f"{title} 在SKIP_PUSH_TITLE环境变量内,跳过推送!") 664 | return 665 | 666 | hitokoto = push_config.get("HITOKOTO") 667 | 668 | text = one() if hitokoto else "" 669 | content += "\n\n" + text 670 | 671 | ts = [ 672 | threading.Thread(target=mode, args=( 673 | title, content), name=mode.__name__) 674 | for mode in notify_function 675 | ] 676 | [t.start() for t in ts] 677 | [t.join() for t in ts] 678 | 679 | 680 | def main(): 681 | send("title", "content") 682 | 683 | 684 | if __name__ == "__main__": 685 | main() 686 | --------------------------------------------------------------------------------