koishi-plugin-toram 1.0.0-bata-2 → 1.0.0-bata-3
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/aoandou.js +11 -15
- package/lib/functions.js +3 -3
- package/lib/index.d.ts +5 -1
- package/lib/index.js +10 -6
- package/package.json +1 -1
package/lib/aoandou.js
CHANGED
|
@@ -22,22 +22,18 @@ async function apply(ctx, config) {
|
|
|
22
22
|
ctx.middleware(async (session, next) => {
|
|
23
23
|
logger.info(session);
|
|
24
24
|
const qq = session.userId;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
user.magic += 10;
|
|
36
|
-
await ctx.database.set('toramUser', { qq: qq }, { magic: user.magic });
|
|
37
|
-
}
|
|
38
|
-
await ctx.database.set('toramUser', { qq: qq }, { lastChatTime: new Date().getTime() });
|
|
39
|
-
break;
|
|
25
|
+
let user = await (0, functions_1.getUser)(ctx, session);
|
|
26
|
+
// 赋予初始属性
|
|
27
|
+
if (user === undefined) {
|
|
28
|
+
user = new classes_1.User(qq, session.username);
|
|
29
|
+
await ctx.database.create('toramUser', user);
|
|
30
|
+
}
|
|
31
|
+
// 判断是否今日首次发言
|
|
32
|
+
if ((0, functions_1.isToday)(user.lastChatTime)) {
|
|
33
|
+
user.magic += config.magic_dailyGet;
|
|
34
|
+
await ctx.database.set('toramUser', { qq: qq }, { magic: user.magic });
|
|
40
35
|
}
|
|
36
|
+
await ctx.database.set('toramUser', { qq: qq }, { lastChatTime: new Date().getTime() });
|
|
41
37
|
return next();
|
|
42
38
|
});
|
|
43
39
|
// 注册
|
package/lib/functions.js
CHANGED
|
@@ -22,10 +22,10 @@ exports.isToday = isToday;
|
|
|
22
22
|
// 消耗魔能
|
|
23
23
|
async function magicUse(ctx, session, use) {
|
|
24
24
|
const qq = session.userId;
|
|
25
|
-
const
|
|
26
|
-
const residue =
|
|
25
|
+
const user = await getUser(ctx, session);
|
|
26
|
+
const residue = user.magic - use;
|
|
27
27
|
if (residue >= 0) {
|
|
28
|
-
await ctx.database.set('toramUser', { qq: qq }, { magic:
|
|
28
|
+
await ctx.database.set('toramUser', { qq: qq }, { magic: residue });
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
else {
|
package/lib/index.d.ts
CHANGED
|
@@ -13,10 +13,14 @@ export interface Config {
|
|
|
13
13
|
dishes_return: number;
|
|
14
14
|
levelUP_pet_fixedBossReturn: number;
|
|
15
15
|
levelUP_player_fixedBossReturn: number;
|
|
16
|
+
levelUP_player_wildBossReturn: number;
|
|
16
17
|
magic_dailyGet: number;
|
|
18
|
+
magic_dishes: number;
|
|
19
|
+
magic_levelUP: number;
|
|
20
|
+
magic_levelUP_pet: number;
|
|
21
|
+
magic_update: number;
|
|
17
22
|
maxLevel: number;
|
|
18
23
|
update_return: number;
|
|
19
|
-
levelUP_player_wildBossReturn: number;
|
|
20
24
|
}
|
|
21
25
|
export declare const Config: Schema<Config>;
|
|
22
26
|
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -31,7 +31,7 @@ exports.name = 'toram';
|
|
|
31
31
|
exports.Config = koishi_1.Schema.intersect([
|
|
32
32
|
koishi_1.Schema.object({
|
|
33
33
|
account_qq: koishi_1.Schema.string().description('机器人使用的QQ号'),
|
|
34
|
-
account_qq_guild: koishi_1.Schema.string().description('机器人在频道的QQ号【通过在频道发送 account_qq
|
|
34
|
+
account_qq_guild: koishi_1.Schema.string().description('机器人在频道的QQ号【通过在频道发送 account_qq 获得】'),
|
|
35
35
|
aoandou: koishi_1.Schema.boolean().default(false).description('开启高级魔导书'),
|
|
36
36
|
}).description('机器人'),
|
|
37
37
|
koishi_1.Schema.object({
|
|
@@ -48,6 +48,10 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
48
48
|
koishi_1.Schema.object({
|
|
49
49
|
aoandou: koishi_1.Schema.const(true).required(),
|
|
50
50
|
magic_dailyGet: koishi_1.Schema.number().min(0).default(10).description('每日发言奖励的魔能'),
|
|
51
|
+
magic_dishes: koishi_1.Schema.number().min(0).default(1).description('料理指令消耗魔能'),
|
|
52
|
+
magic_levelUP: koishi_1.Schema.number().min(0).default(1).description('升级指令消耗魔能'),
|
|
53
|
+
magic_levelUP_pet: koishi_1.Schema.number().min(0).default(1).description('练宠指令消耗魔能'),
|
|
54
|
+
magic_update: koishi_1.Schema.number().min(0).default(1).description('更新指令消耗魔能'),
|
|
51
55
|
})
|
|
52
56
|
])
|
|
53
57
|
]);
|
|
@@ -70,7 +74,7 @@ async function apply(ctx, config) {
|
|
|
70
74
|
}, {
|
|
71
75
|
primary: 'id'
|
|
72
76
|
});
|
|
73
|
-
const pluginVersion = '1.0.0-bata-
|
|
77
|
+
const pluginVersion = '1.0.0-bata-3'; // 插件当前版本
|
|
74
78
|
// 更新数据库指令
|
|
75
79
|
ctx.command('updateDatabase').action(async ({ session }) => {
|
|
76
80
|
let version = await ctx.database.get('toram', { database: 'data_version' });
|
|
@@ -120,19 +124,19 @@ async function apply(ctx, config) {
|
|
|
120
124
|
});
|
|
121
125
|
// 料理指令
|
|
122
126
|
ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
|
|
123
|
-
await (0, functions_1.useCommand)('dishes', ctx, session, logger, config,
|
|
127
|
+
await (0, functions_1.useCommand)('dishes', ctx, session, logger, config, config.magic_dishes, args);
|
|
124
128
|
});
|
|
125
129
|
// 升级指令
|
|
126
130
|
ctx.command('升级 <等级数>').action(async ({ session }, ...args) => {
|
|
127
|
-
await (0, functions_1.useCommand)('levelUP', ctx, session, logger, config,
|
|
131
|
+
await (0, functions_1.useCommand)('levelUP', ctx, session, logger, config, config.magic_levelUP, args);
|
|
128
132
|
});
|
|
129
133
|
// 更新指令
|
|
130
134
|
ctx.command('更新').action(async ({ session }) => {
|
|
131
|
-
await (0, functions_1.useCommand)('update', ctx, session, logger, config,
|
|
135
|
+
await (0, functions_1.useCommand)('update', ctx, session, logger, config, config.magic_update);
|
|
132
136
|
});
|
|
133
137
|
// 练宠指令
|
|
134
138
|
ctx.command('练宠 <等级数>').action(async ({ session }, ...args) => {
|
|
135
|
-
await (0, functions_1.useCommand)('levelUP_pet', ctx, session, logger, config,
|
|
139
|
+
await (0, functions_1.useCommand)('levelUP_pet', ctx, session, logger, config, config.magic_levelUP_pet, args);
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
exports.apply = apply;
|