UNPKG

koishi-plugin-zanwo

Version:

QQ 名片赞点赞插件,支持对指定 QQ 号点赞

97 lines (92 loc) 3.99 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/locales/zh_CN.yml var require_zh_CN = __commonJS({ "src/locales/zh_CN.yml"(exports2, module2) { module2.exports = { commands: { zanwo: { description: "赞我", usage: "直接输入即可点赞", examples: "zanwo", messages: { success: "已完成名片赞操作,记得回哦~", failure: "点赞失败惹" } }, zan: { description: "为其他人点赞", usage: "命令后接需要点赞的 QQ 号", examples: "zan 114514\nzan 1919810", messages: { success: "已对目标完成名片赞操作", failure: "无法对目标点赞", noarg: "缺少必要参数,请检查输入" } } } }; } }); // src/index.ts var src_exports = {}; __export(src_exports, { Config: () => Config, apply: () => apply, name: () => name, usage: () => usage }); module.exports = __toCommonJS(src_exports); var import_koishi = require("koishi"); var name = "zanwo"; var usage = ` ![koishi-plugin-zanwo](https://socialify.git.ci/xiaozhu2007/koishi-plugin-zanwo/image?description=1&forks=1&issues=1&language=1&name=1&owner=1&pattern=Signal&pulls=1&stargazers=1&theme=Auto) **<center>本插件支持开箱即用</center>** 本插件支持陌生人点赞 50 次 及 自定义成功失败语句,详情请见本地化 `; var logger = new import_koishi.Logger(name); var Config = import_koishi.Schema.object({ debug: import_koishi.Schema.boolean().description("是否开启调试模式").default(false).experimental() }); function apply(ctx, config) { let globalConfig = config; ctx.i18n.define("zh-CN", require_zh_CN()); ctx.command("zanwo").alias("赞我").action(async ({ session }) => { let num = 0; try { for (let i = 0; i < 5; i++) { await session.bot.internal.sendLike(session.userId, 10); num += 1; if (globalConfig.debug) logger.info(`为 ${session.userId} 点赞了 ${num} 轮`); } return session.text(".success"); } catch (_e) { if (num > 0) return session.text(".success"); return session.text(".failure"); } }); ctx.command("zan <who:text>").action(async ({ session }, who) => { if (!who || who.trim() === "" || who.split(/\s+/).filter(Boolean).length > 1) return session.text(".noarg"); let uid = who.match(/\d+/)?.[0]; if (!uid) return session.text(".noarg"); if (globalConfig.debug) logger.info(`从 ${who} 匹配到 ${uid}`); let num = 0; try { for (let i = 0; i < 5; i++) { await session.bot.internal.sendLike(uid, 10); num += 1; if (globalConfig.debug) logger.info(`为 ${uid} 点赞了 ${num} 轮`); } return session.text(".success"); } catch (e) { if (num > 0) return session.text(".success"); if (globalConfig.debug) logger.warn(`为 ${uid} 点赞失败:${e.message}`); return session.text(".failure"); } }); } __name(apply, "apply"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Config, apply, name, usage });