From 7833d7ba81744d16dee69503d2e9441177a7bf2c Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 8 Jun 2022 16:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Github=20Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report_en.md | 23 +++++++++++++ .github/ISSUE_TEMPLATE/bug_report_zh.md | 23 +++++++++++++ .github/ISSUE_TEMPLATE/feature_request_en.md | 19 +++++++++++ .github/ISSUE_TEMPLATE/feature_request_zh.md | 19 +++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 21 ++++++++++++ .github/workflows/python.yml | 35 ++++++++++++++++++++ telegram_update.py | 22 ++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report_en.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report_zh.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request_en.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request_zh.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/python.yml create mode 100644 telegram_update.py diff --git a/.github/ISSUE_TEMPLATE/bug_report_en.md b/.github/ISSUE_TEMPLATE/bug_report_en.md new file mode 100644 index 0000000..25c6d4c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_en.md @@ -0,0 +1,23 @@ +--- +name: 🐛 Bug Report +about: Submit discovered bugs +--- + + + +### BUG occurrence address + +### What is expected? + +### What is actually happening? + +### Additional info (logs errors etc) + + diff --git a/.github/ISSUE_TEMPLATE/bug_report_zh.md b/.github/ISSUE_TEMPLATE/bug_report_zh.md new file mode 100644 index 0000000..f037505 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_zh.md @@ -0,0 +1,23 @@ +--- +name: 🐛 Bug 报告 +about: 早起的虫子被你抓 +--- + + + +### BUG 发生地址 + +### 预期是什么? + +### 实际发生了什么? + +### 额外信息(日志、报错等) + + diff --git a/.github/ISSUE_TEMPLATE/feature_request_en.md b/.github/ISSUE_TEMPLATE/feature_request_en.md new file mode 100644 index 0000000..b316852 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request_en.md @@ -0,0 +1,19 @@ +--- +name: 🍰 Feature Request +about: Submit a new feature request +--- + + + +### What feature is it? + +### What can this function do? + +### Additional description + + diff --git a/.github/ISSUE_TEMPLATE/feature_request_zh.md b/.github/ISSUE_TEMPLATE/feature_request_zh.md new file mode 100644 index 0000000..805a376 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request_zh.md @@ -0,0 +1,19 @@ +--- +name: 🍰 功能需求 +about: 提交新的功能需求 +--- + + + +### 这是一个什么样的功能? + +### 这个 feature 可以干什么? + +### 额外描述 + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..28c9eff --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,21 @@ +## 该 PR 相关 Issue / Involved issue + +Close # + +## 插件名称 / Name + +``` + +``` + +## 更改检查表 / Change Checklist + +- [ ] 有插件版本号更新 +- [ ] 有多语言支持 + - [ ] CN + - [ ] EN +- [ ] 会触发频率限制 Will trigger a rate limit? + - [ ] 如果会, 是否有对应的措施? If yes, do your code reflect this sign? +- [ ] 添加了新的依赖包 New package added + +## 说明 / Note diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..704b2f9 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,35 @@ +name: Github commit to telegram + +on: + push: + branches: + - v2 + +jobs: + build: + runs-on: ubuntu-latest + steps: + # 此步骤使用 GitHub 的 https://github.com/actions/checkout + - name: checkout actions + uses: actions/checkout@v3 + + # 设置python环境 + # 此步骤使用 GitHub 的 https://github.com/actions/setup-python + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + # 安装依赖 + - name: Install dependencies + run: | + mkdir tmp && cd tmp + python -m pip install --upgrade pip + pip install httpx + + # 发送通知 + - name: Send notice + run: | + cd tmp + cp ../telegram_update.py ./ + python telegram_update.py ${{ secrets.TG_BOT_TOKEN }} diff --git a/telegram_update.py b/telegram_update.py new file mode 100644 index 0000000..62e9501 --- /dev/null +++ b/telegram_update.py @@ -0,0 +1,22 @@ +import json, time, sys +from httpx import get, post + +token = str(sys.argv[1]) +main = json.loads(get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").content) +text = "#更新日志 #pyro #" + main['commit']['author']['name'].replace('_', '') + \ + ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/TeamPGM/PagerMaid_Plugins_Pyro/commit/' + \ + main['sha'] + '): ' + main['commit']['message'] +push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown', + 'text': text} +url = 'https://api.telegram.org/bot' + token + '/sendMessage' +try: + main_req = post(url, data=push_content) +except: + pass +push_content['chat_id'] = '-1001319957857' +time.sleep(1) +try: + main_req = post(url, data=push_content) +except: + pass +print(main['sha'] + " ok!")