koishi-plugin-tmp-bot 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/command/tmpBind.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// 更新数据库
|
|
19
|
-
guildBind.saveOrUpdate(ctx.database, session.platform, session.
|
|
19
|
+
guildBind.saveOrUpdate(ctx.database, session.platform, session.userId, session.author.username, tmpId)
|
|
20
20
|
|
|
21
21
|
return `绑定成功 ( ${playerInfo.data.name} )`
|
|
22
22
|
}
|
|
@@ -16,7 +16,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
16
16
|
|
|
17
17
|
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
18
18
|
if (!tmpId) {
|
|
19
|
-
let guildBindData = await guildBind.get(ctx.database, session.platform, session.
|
|
19
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
20
20
|
if (!guildBindData) {
|
|
21
21
|
return `请输入正确的玩家编号`
|
|
22
22
|
}
|
package/lib/command/tmpQuery.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
24
24
|
|
|
25
25
|
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
26
26
|
if (!tmpId) {
|
|
27
|
-
let guildBindData = await guildBind.get(ctx.database, session.platform, session.
|
|
27
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
28
28
|
if (!guildBindData) {
|
|
29
29
|
return `请输入正确的玩家编号`
|
|
30
30
|
}
|
package/lib/command/tmpServer.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const truckersMpApi = require('../api/TruckersMpApi')
|
|
2
2
|
|
|
3
|
-
module.exports = async (ctx, cfg) => {
|
|
3
|
+
module.exports = async (ctx, cfg, game) => {
|
|
4
4
|
// 查询服务器信息
|
|
5
5
|
let serverData = await truckersMpApi.servers(ctx.http)
|
|
6
6
|
if (serverData.error) {
|
|
7
7
|
return '查询服务器失败,请稍后重试'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
let etsServerList = serverData.data.filter(server => server.game ===
|
|
10
|
+
// 过滤服务器
|
|
11
|
+
let etsServerList = serverData.data.filter(server => server.game === game)
|
|
12
12
|
|
|
13
13
|
// 构建消息
|
|
14
14
|
let message = ''
|
|
@@ -3,13 +3,11 @@ module.exports = {
|
|
|
3
3
|
* 获取绑定信息
|
|
4
4
|
* @param db 数据源
|
|
5
5
|
* @param platform 平台
|
|
6
|
-
* @param guildId 群组编号
|
|
7
6
|
* @param userId 用户编号
|
|
8
7
|
*/
|
|
9
|
-
async get (db, platform,
|
|
8
|
+
async get (db, platform, userId) {
|
|
10
9
|
const guildBindList = await db.get('tmp_guild_bind', {
|
|
11
10
|
platform,
|
|
12
|
-
guild_id: guildId,
|
|
13
11
|
user_id: userId
|
|
14
12
|
})
|
|
15
13
|
|
|
@@ -23,13 +21,12 @@ module.exports = {
|
|
|
23
21
|
* 新增或更新绑定信息
|
|
24
22
|
* @param db 数据源
|
|
25
23
|
* @param platform 平台
|
|
26
|
-
* @param guildId 群组编号
|
|
27
24
|
* @param userId 用户编号
|
|
28
25
|
* @param userName 用户昵称
|
|
29
26
|
* @param tmpId TMP ID
|
|
30
27
|
*/
|
|
31
|
-
saveOrUpdate (db, platform,
|
|
32
|
-
this.get(db, platform,
|
|
28
|
+
saveOrUpdate (db, platform, userId, userName, tmpId) {
|
|
29
|
+
this.get(db, platform, userId).then((data) => {
|
|
33
30
|
if (data) {
|
|
34
31
|
db.set('tmp_guild_bind', data.id, {
|
|
35
32
|
tmp_id: tmpId,
|
|
@@ -38,7 +35,6 @@ module.exports = {
|
|
|
38
35
|
} else {
|
|
39
36
|
db.create('tmp_guild_bind', {
|
|
40
37
|
platform: platform,
|
|
41
|
-
guild_id: guildId,
|
|
42
38
|
user_id: userId,
|
|
43
39
|
user_name: userName,
|
|
44
40
|
tmp_id: tmpId
|
package/lib/database/model.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -24,7 +24,8 @@ function apply(ctx, cfg) {
|
|
|
24
24
|
model(ctx);
|
|
25
25
|
// 注册指令
|
|
26
26
|
ctx.command('tmpquery <tmpId>').action(async ({ session }, tmpId) => await tmpQuery(ctx, cfg, session, tmpId));
|
|
27
|
-
ctx.command('
|
|
27
|
+
ctx.command('tmpserverats').action(async () => await tmpServer(ctx, cfg, 'ATS'));
|
|
28
|
+
ctx.command('tmpserverets').action(async () => await tmpServer(ctx, cfg, 'ETS2'));
|
|
28
29
|
ctx.command('tmpbind <tmpId>').action(async ({ session }, tmpId) => await tmpBind(ctx, cfg, session, tmpId));
|
|
29
30
|
ctx.command('tmptraffic <serverName>').action(async ({ session }, serverName) => await tmpTraffic(ctx, cfg, serverName));
|
|
30
31
|
ctx.command('tmpposition <tmpId>').action(async ({ session }, tmpId) => await tmpPosition(ctx, cfg, session, tmpId));
|