{"id":13498673,"url":"https://github.com/shirok1/e5-api-renew-scf","last_synced_at":"2025-09-01T04:34:23.460Z","repository":{"id":183952955,"uuid":"248113252","full_name":"shirok1/e5-api-renew-scf","owner":"shirok1","description":"本项目已进入半废弃状态（因为我自己的开发者订阅在2020年12月掉了）所以这里可能只能提供基础技术指导——[腾讯云函数专用]通过重复调用MS Graph API来试图续订Office 365开发者试用","archived":false,"fork":false,"pushed_at":"2020-03-31T03:56:06.000Z","size":9,"stargazers_count":38,"open_issues_count":2,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-30T04:58:21.043Z","etag":null,"topics":["office-365","serverless","tencent-cloud","tencent-scf"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shirok1.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-18T01:46:11.000Z","updated_at":"2025-04-03T15:13:35.000Z","dependencies_parsed_at":"2023-07-26T14:27:03.233Z","dependency_job_id":null,"html_url":"https://github.com/shirok1/e5-api-renew-scf","commit_stats":null,"previous_names":["shirok1/e5-api-renew-scf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shirok1/e5-api-renew-scf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirok1%2Fe5-api-renew-scf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirok1%2Fe5-api-renew-scf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirok1%2Fe5-api-renew-scf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirok1%2Fe5-api-renew-scf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shirok1","download_url":"https://codeload.github.com/shirok1/e5-api-renew-scf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirok1%2Fe5-api-renew-scf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273073425,"owners_count":25040721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["office-365","serverless","tencent-cloud","tencent-scf"],"created_at":"2024-07-31T21:00:40.708Z","updated_at":"2025-09-01T04:34:23.438Z","avatar_url":"https://github.com/shirok1.png","language":"Python","funding_links":[],"categories":["应用场景"],"sub_categories":["打卡/签到/抽奖"],"readme":"# E5 Renew SCF\n\n如题，[原版刷API脚本](http://file.heimu.ltd/1.py)的修改版，单次执行，专门用于腾讯云的无服务器云函数。\n\n### 配置\n\n参数获取请参见[office e5刷API脚本分享以及教程](https://blog.432100.xyz/index.php/archives/50/)、[E5刷API脚本分享以及教程](https://huengyamm.xyz/2020/03/15/E5-API/)（后面这个有图）。\n\n入口函数为`index.exe`。\n\n需要预先配置以下环境变量：\n\n`Region`：该云函数所在服务器地域，地域代码参见[地域列表](https://cloud.tencent.com/document/product/583/17238#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8)\n\n`refresh_token`：`rclone`所获取的同名参数，[点击这里下载`rclone`](http://file.heimu.ltd/rclone.exe)\n\n`ms_id`：Azure AD上的**应用程序(客户端) ID**\n\n`ms_secret`：Azure AD上的**客户端密码**（不是用户密码）\n\n`SecretId`、`SecretKey`：先到腾讯云[API密钥管理](https://console.cloud.tencent.com/cam/capi)创建，用于刷新环境变量中的`refresh_token`\n\n如果你有新的API要加入，只要请求的header格式一致，可以直接加入`api_list`列表（那两个`messageRules`是原本就有两条的，我暂且蒙在鼓里）。\n\n另外，云函数不会自己运行，请自行设置触发器。\n\n**如果你想使用子账号，请注意给予的权限中要包括以下Action：**\n\n| Action名称                             | 描述           |\n| -------------------------------------- | -------------- |\n| GetFunction                            | 获取函数详情   |\n| UpdateFunctionConfiguration            | 更新函数配置   |\n| SetTrigger（仅设置随机时间需要，下同） | 设置函数触发器 |\n| UpdateTrigger                          | 更新触发器配置 |\n| DeleteTrigger                          | 删除函数触发器 |\n\n### 随机时间\n\n原本的设想是直接删除旧的触发器，然后添加一个随机时间的触发器，没想到居然不行。\n\n\u003e [TencentCloudSDKException] code:FailedOperation.CreateTrigger message:创建触发器失败 (当前函数状态无法进行此操作)\n\n明明连修改环境变量都可以……没办法，不能在一个函数内实现随机时间了。（除非你想靠`sleep(random())`卡时间，但这样会浪费不少计费时间）\n\n如果你不嫌麻烦的话，确实可以通过两个函数互相调用来实现随机时间。\n\n#### A+B类型\n\n通过用两个具有完整功能的函数互相设置定时触发器来实现。\n\n环境变量：\n\n`TrigUpdateType`：*AB*\n\n**注意：**云函数提供了包括环境变量在内的**复制**功能。使用复制功能前不要在环境变量中填写`refresh_token`。\n\n`AnotherFunctionName`：另一个函数的`FunctionName`\n\n`AnotherRegion`：（可选）另一个函数的`Region`，默认相同\n\n`AnotherNamespace`：（可选）另一个函数的`Namespace`，默认相同\n\n`random_time_lowerlimit`、`random_time_toplimit`：（可选）随机时间的下限、上限，默认150、300（秒）\n\n`TriggerName`：（可选）触发器的名称，每次更新都会先删除这个名字的触发器再添加一个同名的，默认值为*RandomTimer*。\n\n无论使用哪种类型，建议只设置一个api触发器，因为程序在初次运行后，就能自动递归触发下一次。\n\n### 响应\n\n目前还想不到能响应什么有用的东西，毕竟大部分时间都是无值守运行。\n\n所有`print()`的输出请到云函数的运行日志查看。\n\n### 消耗\n\n测试挂了一天，设置的触发器每5分钟触发一次，共使用资源约120GBs，出流量0.01GB，完全不会超出免费额度；另外，每次触发平均耗时4s，内存消耗基本都在20MB左右。\n\n### TODO\n\n- [x] ~~自行递归添加下一个触发器（以实现真正随机时间而不是靠`sleep(random())`卡时间实现）~~\n  \n- [x] 搞懂为什么不能在定义全局变量的时候用环境变量赋值\n\n \u003e 目前自行定义的环境变量和一些会有变动的环境只能在入口函数中获取，是因为是在调用入口函数的时候注入的。——腾讯云工作人员回复（为什么不写在文档里？）\n\n- [ ] 把那些手打的`params`用字典转json代替（对于那种连多打一个逗号都要报错的解析器表示强烈cnm\n\n- [ ] 欢迎issue。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshirok1%2Fe5-api-renew-scf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshirok1%2Fe5-api-renew-scf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshirok1%2Fe5-api-renew-scf/lists"}