Skip to content

Commit

Permalink
refactor(code): 使用 TypeScript 重写所有逻辑
Browse files Browse the repository at this point in the history
refactor(ffmpeg): 重构 `FFmpeg` 模块调用,使用回调函数替换原有的成功与失败处理,使用 `Karin` 的原生方法
refactor(push): 重构推送的判断逻辑
refactor(push): 独立推送相关配置
refactor(networks): 重构请求模块,请求库替换为 `axios`
feat: 添加数据存储的相关类型声明
feat: 添加 `#抖音/B站全部强制推送`
feat: 新增抖音直播推送
feat: 新增上传模块与相关配置文件
feat: 新增视频压缩机制
feat: 抖音B站推送新增 `banWorks` 与 `banTags`机制
feat: 新增抖音推送图集解析
feat: 添加部分debug日志供调试
feat: 图片渲染新增添加全局 `浅色` 与 `深色` 模式与开关切换
feat: 新增 `#抖音扫码登录` 仅限Windows系统可用
feat: B站推送图给UP主添加头像框
fix: 修复n个bug
fix: 修复抖音合辑解析失败
fix: 修复B站web地址匹配错误
fix: 使用本地二维码渲染 `qrcode.min.js` 解决部分网络环境下CDN无法正常访问导致的二维码渲染失败的问题
fix: 修复了所有的类型错误
fix: 修复评论图中的评论图片渲染失败的问题
fix: 修复了B站获取视频大小需要等待视频下载完成的问题
fix: 修复B站后台幽灵推送
fix: 修复抖音直播解析
perf: 优化了所有推送图的UI
perf: 优化了 `#kkk帮助` 、 `#kkk更新日志` 和 `#kkk设置` 的UI
perf: 设置推送的回复信息添加群名字
perf: 优化了部分开关判断
perf: 解耦解析库,使用回npm进行管理
perf: 优化部分提示
perf: 尽可能导入node原生库
style: 优化了代码结构、项目结构与命名
style: 自动编译到build分支的工作流
style: 编译后删除 `package.json` 的开发依赖
  • Loading branch information
ikenxuan committed Nov 27, 2024
0 parents commit 6fa2b44
Show file tree
Hide file tree
Showing 700 changed files with 18,091 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.html linguist-language=TypeScript
*.css linguist-language=TypeScript
*.js linguist-language=TypeScript
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "sqlite3"
- dependency-name: "sequelize"
171 changes: 171 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: Build, Bump Version, and Commit

on:
push:
branches:
- main
workflow_dispatch: # 允许手动触发

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: 拉取代码
uses: actions/checkout@v4

- name: 安装node
uses: actions/setup-node@v4
with:
node-version: 18.20.4
registry-url: "https://registry.npmjs.org"

- name: 安装pnpm
uses: pnpm/action-setup@v2
with:
version: 9.7.1

- name: 安装依赖
run: |
pnpm install
pnpm add node-karin@latest chokidar@latest lodash@latest yaml@latest
- name: 放弃 package.json 的本地更改
run: |
git checkout HEAD package.json
- name: 删除 pnpm-lock.yaml
run: rm -rf pnpm-lock.yaml

- name: 编译
run: pnpm build

- name: 设置时区
run: |
sudo timedatectl set-timezone Asia/Shanghai
- name: 设置git用户名和邮箱
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: 创建临时文件夹存储编译后的lib文件夹
run: |
mkdir ./../temp
- name: 复制编译后的lib文件夹到临时文件夹
run: |
cp -r ./lib ./../temp/lib
- name: 检查并创建空的 build 分支
run: |
git fetch origin
# 检查 build 分支是否存在
if git show-ref --verify --quiet refs/heads/build; then
echo "Build branch exists locally. Switching to it."
git checkout build
else
# 检查远程是否有 build 分支
if git ls-remote --exit-code --heads origin build; then
echo "Build branch exists remotely. Fetching and switching to it."
git checkout build
else
# build 分支不存在,创建一个空的 build 分支
echo "Build branch does not exist. Creating an empty build branch."
git checkout --orphan build # 创建一个没有历史记录的空分支
git reset --hard # 重置所有文件
git clean -fdx # 删除未被 Git 管理的文件和文件夹
echo "Empty build branch created."
git commit --allow-empty -m "Initial empty commit on build branch"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} build # 推送到远程仓库
fi
fi
- name: 切换到 build 分支
run: |
git fetch origin build
git checkout build
- name: 删除build分支上的lib文件夹
run: |
rm -rf lib
- name: 复制编译后的lib文件夹到 build 分支
run: |
cp -r ./../temp/lib ./
- name: 删除临时文件夹
run: |
rm -rf ./../temp
- name: 从main分支复制文件到build分支
run: |
git checkout main -- package.json CHANGELOG.md README.md config resources LICENSE
- name: 删除依赖文件夹 node_modules
run: |
rm -rf node_modules
- name: 将文件整理到 karin-plugin-kkk 文件夹
run: |
mkdir -p karin-plugin-kkk
find . -path "./.git" -prune -o -type f -print | while read file; do
mkdir -p "karin-plugin-kkk/$(dirname "$file")"
cp "$file" "karin-plugin-kkk/$file"
done
- name: 创建 build.zip
run: zip -r build.zip karin-plugin-kkk

- name: 上传 build.zip
uses: actions/upload-artifact@v4
with:
name: build-zip
path: build.zip

- name: 删除 karin-plugin-kkk 文件夹
run: rm -rf karin-plugin-kkk

- name: 删除开发依赖
run: npm run clean

- name: 根据main分支的commit信息生成提交消息
run: |
git add .
git reset build.zip
if [ -z "$(git diff --cached --name-only)" ]; then
echo "No changes detected"
exit 0
else
git commit -m "chore(build): ${{ github.event.head_commit.message }}"
fi
- name: 设置 build 分支的上游分支
run: git push --set-upstream origin build

- name: 推送到 build 分支
uses: ad-m/github-push-action@master
with:
branch: build
github_token: ${{ secrets.GITHUB_TOKEN }}
force_with_lease: true
args: --set-upstream

- name: 更新版本号
uses: google-github-actions/release-please-action@v3
id: release_please
with:
release-type: node
package-name: 'karin-plugin-kkk'

- name: 发布到 npm
run: npm run pub
if: ${{ steps.release_please.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}


- name: 上传 release
if: ${{ steps.release_please.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ steps.release_please.outputs.tag_name }} build.zip
22 changes: 22 additions & 0 deletions .github/workflows/issue_close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 60
days-before-issue-close: 30
stale-issue-label: "stale"
stale-issue-message: "📅 你好 @${{ github.event.issue.user.login }},这个问题已经过期了,因为它已经开放了30天,没有任何活动。"
close-issue-message: "🚫 你好 @${{ github.event.issue.user.login }},此问题已关闭,因为它已被标记为过期后14天处于非活动状态。。"
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/issue_geetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
issues:
types: [labeled]

jobs:
create-comment:
runs-on: ubuntu-latest
steps:
- name: Create comment for enhancement
if: github.event.label.name == 'enhancement'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
body: |
你好 @${{ github.event.issue.user.login }},我们已经记录了你的新功能提议。如果你有任何具体的实现想法或设计草图,欢迎随时分享给我们。
emoji: 'eyes'

- name: Create comment for bug
if: github.event.label.name == 'bug'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
body: |
你好 @${{ github.event.issue.user.login }},看来我们的代码不小心打了个盹儿。别担心,我们已经唤醒了开发团队,他们正快马加鞭地赶来修复!🔨🐞
emoji: 'eyes'
20 changes: 20 additions & 0 deletions .github/workflows/issue_similarity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 问题相似性分析
name: Issues Similarity Analysis

on:
issues:
types: [opened, edited]

jobs:
similarity-analysis:
runs-on: ubuntu-latest
steps:
- name: analysis
uses: actions-cool/issues-similarity-analysis@v1
with:
filter-threshold: 0.5
comment-title: '### 似乎有相似的问题'
comment-body: '${index}. ${similarity} #${number}'
show-footer: false
show-mentioned: true
since-days: 730
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config/config/
lib/
node_modules/

pnpm-lock.yaml
package-lock.json
yarn.lock
Empty file added CHANGELOG.md
Empty file.
Loading

0 comments on commit 6fa2b44

Please sign in to comment.