koishi-plugin-common
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -7,3 +7,5 @@ import { Context } from 'koishi-core'; | ||
refreshGroupName?: number; | ||
includeUsers?: number[]; | ||
includeGroups?: number[]; | ||
} | ||
export declare function apply(ctx: Context, config?: DebugOptions): void; |
@@ -20,3 +20,3 @@ "use strict"; | ||
function apply(ctx, config = {}) { | ||
const { refreshUserName = koishi_utils_1.Time.hour, refreshGroupName = koishi_utils_1.Time.hour, showUserId, showGroupId } = config; | ||
const { refreshUserName = koishi_utils_1.Time.hour, refreshGroupName = koishi_utils_1.Time.hour, includeUsers = [], includeGroups = [], showUserId, showGroupId, } = config; | ||
const logger = new koishi_utils_1.Logger('message', true); | ||
@@ -85,3 +85,3 @@ koishi_utils_1.Logger.levels.message = 3; | ||
}); | ||
ctx.on('message', async (session) => { | ||
async function onMessage(session) { | ||
const groupName = await getGroupName(session); | ||
@@ -91,5 +91,11 @@ const senderName = getSenderName(session); | ||
logger.debug(`[${groupName}] ${senderName}: ${message}`); | ||
}); | ||
} | ||
if (includeUsers) { | ||
ctx.private(...includeUsers).on('message', onMessage); | ||
} | ||
if (includeGroups) { | ||
ctx.group(...includeGroups).on('message', onMessage); | ||
} | ||
} | ||
exports.apply = apply; | ||
//# sourceMappingURL=debug.js.map |
@@ -17,3 +17,2 @@ import { App, Session } from 'koishi-core'; | ||
onGroupInvite?: RequestHandler; | ||
blackList?: string[]; | ||
respondents?: Respondent[]; | ||
@@ -20,0 +19,0 @@ throttle?: ThrottleConfig | ThrottleConfig[]; |
@@ -21,10 +21,3 @@ "use strict"; | ||
}); | ||
const { blackList = [], respondents = [], welcome = defaultMessage } = options; | ||
blackList.length && ctx.prependMiddleware((session, next) => { | ||
for (const word of blackList) { | ||
if (session.message.includes(word)) | ||
return; | ||
} | ||
return next(); | ||
}); | ||
const { respondents = [], welcome = defaultMessage } = options; | ||
respondents.length && ctx.middleware((session, next) => { | ||
@@ -31,0 +24,0 @@ const message = koishi_utils_1.simplify(session.message); |
@@ -29,6 +29,8 @@ "use strict"; | ||
ctx.plugin(require('./admin')); | ||
ctx.plugin(require('./debug'), config.debug); | ||
ctx.plugin(require('./info')); | ||
if (config.debug) { | ||
ctx.plugin(require('./debug'), config.debug); | ||
} | ||
} | ||
exports.apply = apply; | ||
//# sourceMappingURL=index.js.map |
@@ -42,3 +42,3 @@ "use strict"; | ||
const interactions = {}; | ||
config.operator && ctx.command('feedback', '发送反馈信息给作者') | ||
config.operator && ctx.command('feedback <message...>', '发送反馈信息给作者') | ||
.userFields(['name', 'id']) | ||
@@ -45,0 +45,0 @@ .action(async ({ session }, text) => { |
{ | ||
"name": "koishi-plugin-common", | ||
"description": "Common plugins for Koishi", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"main": "dist/index.js", | ||
@@ -34,3 +34,3 @@ "typings": "dist/index.d.ts", | ||
"peerDependencies": { | ||
"koishi-core": "^2.2.2" | ||
"koishi-core": "^2.3.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
56809
724