-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
4,033 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true | ||
}, | ||
extends: 'eslint:recommended', | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true | ||
}, | ||
files: [ | ||
'.eslintrc.{js,cjs}' | ||
], | ||
parserOptions: { | ||
sourceType: 'script' | ||
} | ||
} | ||
], | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module' | ||
}, | ||
ignorePatterns: [ | ||
'test/**' | ||
], | ||
rules: { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: 更新版本号 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 更新版本号 | ||
uses: googleapis/release-please-action@v4 | ||
id: release_please | ||
with: | ||
release-type: node | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
bump-minor-pre-major: true | ||
version-file: package.json | ||
fork: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test | ||
**/test.js | ||
**/test.ts | ||
node_modules | ||
config/config | ||
data | ||
data.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Changelog | ||
|
||
## 1.3.0 (2024-11-17) | ||
|
||
|
||
### Features | ||
|
||
* steam愿望单 | ||
|
||
## 1.2.0 (2024-11-16) | ||
|
||
|
||
### Features | ||
|
||
* steam库存 | ||
* steam最近游玩 | ||
|
||
## 1.1.0 (2024-11-16) | ||
|
||
|
||
### Features | ||
|
||
* steam信息 | ||
|
||
## 1.0.0 (2024-11-15) | ||
|
||
|
||
### Features | ||
|
||
* steam绑定 | ||
* steam解除绑定 | ||
* 游玩通知 结束通知 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Steam Plugin | ||
|
||
<div align="center"> | ||
|
||
**提供 steam 相关功能** | ||
|
||
<br/> | ||
|
||
![GitHub stars](https://img.shields.io/github/stars/XasYer/steam-plugin?style=social) | ||
![GitHub forks](https://img.shields.io/github/forks/XasYer/steam-plugin?style=social) | ||
![GitHub license](https://img.shields.io/github/license/XasYer/steam-plugin) | ||
![GitHub issues](https://img.shields.io/github/issues/XasYer/steam-plugin) | ||
![GitHub pull requests](https://img.shields.io/github/issues-pr/XasYer/steam-plugin) | ||
<br/> | ||
|
||
<img src="https://count.getloli.com/get/@XasYer-steam-plugin?theme=rule34" /> | ||
|
||
</div> | ||
|
||
## 介绍 | ||
|
||
这是一个基于 [Miao-Yunzai](https://gitee.com/yoimiya-kokomi/Miao-Yunzai)&[Trss-Yunzai](https://gitee.com/TimeRainStarSky/Yunzai)的扩展插件, 提供 steam 群友状态播报, steam 库存, steam 愿望单 等功能 | ||
|
||
## 安装 | ||
|
||
### 使用github | ||
```bash | ||
git clone --depth=1 https://github.moeyy.xyz/https://github.com/XasYer/steam-plugin.git ./plugins/steam-plugin | ||
``` | ||
|
||
### 使用gitee | ||
```bash | ||
git clone --depth=1 https://gitee.com/xiaoye12123/steam-plugin.git ./plugins/steam-plugin | ||
``` | ||
|
||
### 安装依赖 | ||
```bash | ||
pnpm install --filter=steam-plugin | ||
``` | ||
|
||
## 功能 | ||
|
||
- [x] steam绑定 | ||
- [x] steam更换绑定 | ||
- [x] steam库存 | ||
- [x] steam最近游玩 | ||
- [x] steam愿望单 | ||
- [x] 群友状态播报 | ||
- [ ] 帮助 | ||
- [ ] 设置 | ||
- [ ] steam搜索 | ||
- [ ] steam成就统计 | ||
- [ ] 群友上下线通知 | ||
- [ ] steam喜加一 | ||
- [ ] 开启/关闭推送 | ||
|
||
## 贡献者 | ||
|
||
> 🌟 星光闪烁,你们的智慧如同璀璨的夜空。感谢所有为 **steam-plugin** 做出贡献的人! | ||
<a href="https://github.com/XasYer/steam-plugin/graphs/contributors"> | ||
<img src="https://contrib.rocks/image?repo=XasYer/steam-plugin" /> | ||
</a> | ||
|
||
![Alt](https://repobeats.axiom.co/api/embed/aafe6a6a7a72df285ae3965974546314c467db8d.svg "Repobeats analytics image") | ||
|
||
## 其他 | ||
|
||
如果觉得此插件对你有帮助的话,可以点一个 star,你的支持就是不断更新的动力~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { utils, db } from '#models' | ||
|
||
export const rule = { | ||
bind: { | ||
reg: /^#?steam(?:[切更]换)?(?:绑定|bind)\s*(\d+)?$/i, | ||
fnc: async e => { | ||
// 如果是主人可以at其他用户进行绑定 | ||
const uid = utils.getAtUid(e.isMaster ? e.at : '', e.user_id) | ||
const textId = rule.bind.reg.exec(e.msg)[1] | ||
if (!textId) { | ||
const userBindAll = await db.UserTableGetDataByUserId(uid) | ||
if (!userBindAll.length) { | ||
await e.reply('要和SteamID或好友码一起发送哦') | ||
} else { | ||
await e.reply(`已绑定:\n${userBindAll.map(item => `${item.steamId} ${item.isBind ? '√' : ''}`).join('\n')}`) | ||
} | ||
return true | ||
} | ||
const steamId = utils.getSteamId(textId) | ||
// 检查steamId是否被绑定 | ||
const bindInfo = await db.UserTableGetDataBySteamId(steamId) | ||
if (bindInfo) { | ||
if (bindInfo.userId == uid) { | ||
await db.UserTableBindSteamIdByUserId(uid, steamId) | ||
} else { | ||
await e.reply('这个steamId已经被绑定惹, 要不要换一个?') | ||
} | ||
return true | ||
} else { | ||
await db.UserTableAddSteamIdByUserId(uid, steamId) | ||
// TODO: config如果默认开启推送则添加到推送列表 | ||
// 群聊绑定才添加 | ||
if (e.group_id) { | ||
await db.PushTableAddData(uid, steamId, e.self_id, e.group_id) | ||
} | ||
} | ||
const userBindAll = await db.UserTableGetDataByUserId(uid) | ||
await e.reply(`已添加steamId: ${steamId}\n已绑定:\n${userBindAll.map(item => `${item.steamId} ${item.isBind ? '√' : ''}`).join('\n')}`) | ||
return true | ||
} | ||
}, | ||
unbind: { | ||
reg: /^#?steam(?:解除?绑定?|unbind)\s*(\d+)$/i, | ||
fnc: async e => { | ||
const textId = rule.unbind.reg.exec(e.msg)[1] | ||
if (!textId) { | ||
await e.reply('要和SteamID或好友码一起发送哦') | ||
return true | ||
} | ||
// 如果是主人可以at其他用户进行绑定 | ||
const uid = utils.getAtUid(e.isMaster ? e.at : '', e.user_id) | ||
const steamId = utils.getSteamId(textId) | ||
// 检查steamId是否被绑定 | ||
const bindInfo = await db.UserTableGetDataBySteamId(steamId) | ||
if (bindInfo) { | ||
if (bindInfo.userId == uid) { | ||
await db.UserTableDelSteamIdByUserId(uid, steamId) | ||
const userBindAll = await db.UserTableGetDataByUserId(uid) | ||
await e.reply(`已删除steamId: ${steamId}\n已绑定:\n${userBindAll.map(item => `${item.steamId} ${item.isBind ? '√' : ''}`).join('\n')}`) | ||
} else { | ||
await e.reply('只能解绑自己绑定的steamId哦') | ||
} | ||
return true | ||
} | ||
await e.reply('还没有人绑定这个steamId呢') | ||
return true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import fs from 'node:fs' | ||
import { logger } from '#lib' | ||
import { join } from 'node:path' | ||
import { App, Version } from '#components' | ||
import chalk from 'chalk' | ||
import { task } from '#models' | ||
|
||
const startTime = Date.now() | ||
|
||
const path = join(Version.pluginPath, 'apps') | ||
|
||
const files = fs.readdirSync(path).filter(file => file.endsWith('.js')) | ||
|
||
const apps = {} | ||
for (const i of files) { | ||
if (i === 'index.js') continue | ||
try { | ||
const exp = await import(`file://${join(path, i)}`) | ||
const app = new App(exp.app || { | ||
id: i.replace('.js', ''), | ||
name: i.replace('.js', '') | ||
}) | ||
for (const key in exp.rule) { | ||
const rule = exp.rule[key] | ||
app.rule(key, rule.reg, rule.fnc, rule.cfg) | ||
} | ||
apps[app.id] = app.create() | ||
} catch (error) { | ||
logger.error(`[${Version.pluginName}]加载js: apps/${i}错误\n`, error) | ||
} | ||
} | ||
|
||
export { apps } | ||
|
||
task.startTimer() | ||
|
||
const getRandomHexColor = () => { | ||
const randomColor = Math.floor(Math.random() * 16777215).toString(16) | ||
return `#${randomColor.padStart(6, '0')}` | ||
} | ||
|
||
const log = (...args) => logger.info(chalk.hex(getRandomHexColor())(...args)) | ||
|
||
log('-----------------') | ||
log(`${Version.pluginName} v${Version.pluginVersion} 加载成功~ 耗时: ${Date.now() - startTime}ms`) | ||
log('-------^_^-------') |
Oops, something went wrong.