koishi-plugin-toram 1.0.0-bata-3 → 1.0.0-bata-4
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 +15 -11
- package/lib/functions.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/aoandou.js
CHANGED
|
@@ -22,18 +22,22 @@ 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
|
-
|
|
25
|
+
switch (session.event.platform) {
|
|
26
|
+
case 'qqguild':
|
|
27
|
+
let user = await (0, functions_1.getUser)(ctx, session);
|
|
28
|
+
// 赋予初始属性
|
|
29
|
+
if (user === undefined) {
|
|
30
|
+
user = new classes_1.User(qq, session.username);
|
|
31
|
+
await ctx.database.create('toramUser', user);
|
|
32
|
+
}
|
|
33
|
+
// 判断是否今日首次发言
|
|
34
|
+
if ((0, functions_1.isToday)(user.lastChatTime)) {
|
|
35
|
+
user.magic += config.magic_dailyGet;
|
|
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;
|
|
35
40
|
}
|
|
36
|
-
await ctx.database.set('toramUser', { qq: qq }, { lastChatTime: new Date().getTime() });
|
|
37
41
|
return next();
|
|
38
42
|
});
|
|
39
43
|
// 注册
|
package/lib/functions.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.isToday = isToday;
|
|
|
23
23
|
async function magicUse(ctx, session, use) {
|
|
24
24
|
const qq = session.userId;
|
|
25
25
|
const user = await getUser(ctx, session);
|
|
26
|
-
const residue = user
|
|
26
|
+
const residue = (user?.magic ?? 0) - use;
|
|
27
27
|
if (residue >= 0) {
|
|
28
28
|
await ctx.database.set('toramUser', { qq: qq }, { magic: residue });
|
|
29
29
|
return true;
|
package/lib/index.js
CHANGED
|
@@ -74,7 +74,7 @@ async function apply(ctx, config) {
|
|
|
74
74
|
}, {
|
|
75
75
|
primary: 'id'
|
|
76
76
|
});
|
|
77
|
-
const pluginVersion = '1.0.0-bata-
|
|
77
|
+
const pluginVersion = '1.0.0-bata-4'; // 插件当前版本
|
|
78
78
|
// 更新数据库指令
|
|
79
79
|
ctx.command('updateDatabase').action(async ({ session }) => {
|
|
80
80
|
let version = await ctx.database.get('toram', { database: 'data_version' });
|