From 131b230c7abbc3e178cc290116a5828f880862dc Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Thu, 17 Nov 2022 00:15:30 +0800 Subject: [PATCH] =?UTF-8?q?test=20=E9=99=8C=E7=94=9F=E4=BA=BA=E7=82=B9?= =?UTF-8?q?=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/fun.js | 28 ++++++++++++++++------------ model/common.js | 32 ++++++++++++++++++++++++++++++++ model/index.js | 10 ++++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 model/index.js diff --git a/apps/fun.js b/apps/fun.js index 23dc29a..a1cc555 100644 --- a/apps/fun.js +++ b/apps/fun.js @@ -1,11 +1,9 @@ import plugin from '../../../lib/plugins/plugin.js' import fetch from 'node-fetch' -import { segment } from "oicq"; +import { segment } from "oicq" import lodash from 'lodash' -import Cfg from '../model/Config.js'; import { Config } from '../components/index.js' -import uploadRecord from '../model/uploadRecord.js' - +import { Cfg, uploadRecord, common } from '../model/index.js' let heisitype = { "白丝": "baisi", "黑丝": "heisi", @@ -132,10 +130,6 @@ export class example extends plugin { /**点赞 */ async zan(e) { - /**判断是否为好友 */ - let isFriend = await Bot.fl.get(e.user_id) - if (!isFriend) return e.reply("不加好友不点🙄", true) - /** 点赞成功回复的图片*/ let imgs = [ "https://xiaobai.klizi.cn/API/ce/zan.php?qq=", @@ -150,17 +144,27 @@ export class example extends plugin { /** 执行点赞*/ let n = 0; + let failsmsg = '' while (true) { - let res = await Bot.sendLike(e.user_id, 10) - if (!res) { + // let res = await Bot.sendLike(e.user_id, 10) + let res = await common.thumbUp(e.user_id, 10) + if (res.code != 0) { + if (res.code == 1) { + failsmsg = "点赞失败,请检查是否开启陌生人点赞或添加好友" + } else { + failsmsg = res.msg + } break; } else { n += 10; } } + /**判断是否为好友 */ + let isFriend = await Bot.fl.get(e.user_id) + // if (!isFriend) return e.reply("不加好友不点🙄", true) /**回复的消息 */ - let success_result = ["\n", `给你点了${n}下哦,记得回我~`, success_img] - let failds_result = ["\n", "今天点过了,害搁这讨赞呐", failds_img] + let success_result = ["\n", `给你点了${n}下哦,记得回我~${isFriend ? "" : "(如点赞失败请添加好友)"}`, success_img] + let failds_result = ["\n", failsmsg, failds_img] /**判断点赞是否成功*/ let msg = n > 0 ? success_result : failds_result diff --git a/model/common.js b/model/common.js index 9a21de6..0081ea6 100644 --- a/model/common.js +++ b/model/common.js @@ -1,3 +1,4 @@ +import { core } from "oicq"; export default new class common { @@ -66,6 +67,37 @@ export default new class common { return parseInt(arr.join('')) } + /** + * @description: 陌生人点赞 + * @param {Number} uid QQ号 + * @param {Number} times 数量 + * @return {Object} + */ + async thumbUp(uid, times = 1) { + if (times > 20) + times = 20; + let ReqFavorite; + if (Bot.fl.get(uid)) { + ReqFavorite = core.jce.encodeStruct([ + core.jce.encodeNested([ + Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160131", "hex") + ]), + uid, 0, 1, Number(times) + ]); + } + else { + ReqFavorite = core.jce.encodeStruct([ + core.jce.encodeNested([ + Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160135", "hex") + ]), + uid, 0, 5, Number(times) + ]); + } + const body = core.jce.encodeWrapper({ ReqFavorite }, "VisitorSvc", "ReqFavorite", Bot.sig.seq + 1); + const payload = await Bot.sendUni("VisitorSvc.ReqFavorite", body); + let result = core.jce.decodeWrapper(payload)[0]; + return { code: result[3], msg: result[4] }; + } } \ No newline at end of file diff --git a/model/index.js b/model/index.js new file mode 100644 index 0000000..82f0437 --- /dev/null +++ b/model/index.js @@ -0,0 +1,10 @@ +import Browser from "./Browser.js"; +import common from "./common.js"; +import Cfg from "./Config.js"; +import CPU from "./CPU.js"; +import Pixiv from "./Pixiv.js"; +import setu from "./setu.js"; +import uploadRecord from "./uploadRecord.js"; +import YamlReader from "./YamlReader.js"; + +export { Browser, common, Cfg, CPU, Pixiv, setu, uploadRecord, YamlReader } \ No newline at end of file