UNPKG

koishi-plugin-newbingchat

Version:

不需要proxy即可使用的newbing AI,基于NewbingGoGo。

54 lines (53 loc) 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.name = void 0; const koishi_1 = require("koishi"); const dialog_1 = require("./dialog"); exports.name = 'newbingchat'; class NewBingChat { constructor(ctx, config) { ctx.middleware(async (session, next) => { const user = await session.getUser(session.userId); if (user.authority < config.auth) { return next(); } if (config.disableGroup && session.guildId) { return next(); } if (config.disablePrives && !session.guildId) { return next(); } let newBingSession = dialog_1.NewBingSessionClass.getChatSession(session.guildId + session.userId, config); newBingSession.start(config.origin, config.msgFilter).then(() => { newBingSession.sendMessage(session.content, (status, reply) => { session.send(reply); }); }); }); ctx.on('dispose', () => { // 在插件停用时关闭端口 for (let [key, value] of dialog_1.NewBingSessionClass.SessionMap) { value.bingChatWs.close(); } }); } } (function (NewBingChat) { NewBingChat.Config = koishi_1.Schema.object({ origin: koishi_1.Schema.string().description("魔法链接 <a href='https://gitee.com/jja8/NewBingGoGo.wikis/blob/master/%E5%88%9B%E5%BB%BA%E9%AD%94%E6%B3%95%E9%93%BE%E6%8E%A5/%E4%BD%BF%E7%94%A8%E5%85%8D%E8%B4%B9%E7%9A%84%E7%9A%84%E4%BA%91%E6%9C%8D%E5%8A%A1%E6%8F%90%E4%BE%9B%E5%95%86%E5%88%9B%E5%BB%BA%E9%AD%94%E6%B3%95%E9%93%BE%E6%8E%A5.md'>如何创建魔法链接?</a>").default("newbing.vusv.cn"), auth: koishi_1.Schema.number().description("聊天的最低权限").default(1), chatType: koishi_1.Schema.union(["Creative", "Balanced", "Precise"]).description("聊天类型 创造/平衡/精确").default("Creative"), msgFilter: koishi_1.Schema.object({ InternalLoaderMessage: koishi_1.Schema.boolean().description("为你生成答案提示").default(true), RenderCardRequest: koishi_1.Schema.boolean().description("搜索的关键词提示").default(true), InternalSearchQuery: koishi_1.Schema.boolean().description("搜索请求提示,形如:Searching the web for: `关键词`").default(false), SuggestedResponses: koishi_1.Schema.boolean().description("建议答复").default(false), }).description("msgFilter 配置你要过滤的消息"), disablePrives: koishi_1.Schema.boolean().description("禁用私聊").default(false), disableGroup: koishi_1.Schema.boolean().description("禁用群聊").default(true), cookies: koishi_1.Schema.array(koishi_1.Schema.string()).description("配置你的微软cookie").default([ "_U=..." ]), }); })(NewBingChat || (NewBingChat = {})); exports.default = NewBingChat;