mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 01:21:55 +00:00
V3支持戳一戳
This commit is contained in:
parent
d203b2743d
commit
b09be93651
@ -114,9 +114,7 @@ class Puppeteer {
|
|||||||
this.shoting.push(name)
|
this.shoting.push(name)
|
||||||
const page = await this.browser.newPage()
|
const page = await this.browser.newPage()
|
||||||
page.setCacheEnabled(true)
|
page.setCacheEnabled(true)
|
||||||
await page.goto(`file://${_path}${lodash.trim(savePath, '.')}`, {
|
await page.goto(`file://${_path}${lodash.trim(savePath, '.')}`, data.pageGotoParams || {})
|
||||||
waitUntil: 'networkidle0'
|
|
||||||
})
|
|
||||||
let body = await page.$('#container') || await page.$('body')
|
let body = await page.$('#container') || await page.$('body')
|
||||||
await page.waitForSelector('#container')
|
await page.waitForSelector('#container')
|
||||||
let randData = {
|
let randData = {
|
||||||
|
@ -58,11 +58,6 @@ app.reg('wife', wife, {
|
|||||||
describe: '#老公 #老婆 查询'
|
describe: '#老公 #老婆 查询'
|
||||||
})
|
})
|
||||||
|
|
||||||
app.reg('pock-wife', pokeWife, {
|
|
||||||
rule: '#poke#',
|
|
||||||
describe: '#老公 #老婆 查询'
|
|
||||||
})
|
|
||||||
|
|
||||||
app.reg('original-pic', getOriginalPicture, {
|
app.reg('original-pic', getOriginalPicture, {
|
||||||
rule: /^#?(获取|给我|我要|求|发|发下|发个|发一下)?原图(吧|呗)?$/,
|
rule: /^#?(获取|给我|我要|求|发|发下|发个|发一下)?原图(吧|呗)?$/,
|
||||||
describe: '【#原图】 回复角色卡片,可获取原图'
|
describe: '【#原图】 回复角色卡片,可获取原图'
|
||||||
@ -133,7 +128,7 @@ export async function character (e) {
|
|||||||
}
|
}
|
||||||
if (e.isPrivate) {
|
if (e.isPrivate) {
|
||||||
if ((e.sub_type === 'friend' && Cfg.get('profile.friend.status') === false) ||
|
if ((e.sub_type === 'friend' && Cfg.get('profile.friend.status') === false) ||
|
||||||
(e.sub_type === 'group' && Cfg.get('profile.stranger.status') === false)) {
|
(e.sub_type === 'group' && Cfg.get('profile.stranger.status') === false)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if (e.isGroup) {
|
} else if (e.isGroup) {
|
||||||
|
@ -86,6 +86,8 @@ export async function wife (e) {
|
|||||||
isSelf = false
|
isSelf = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let renderType = (action === '卡片' ? 'card' : 'photo')
|
||||||
|
let addRet = []
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case '卡片':
|
case '卡片':
|
||||||
case '照片':
|
case '照片':
|
||||||
@ -93,9 +95,7 @@ export async function wife (e) {
|
|||||||
case '图片':
|
case '图片':
|
||||||
case '写真':
|
case '写真':
|
||||||
// 展示老婆卡片
|
// 展示老婆卡片
|
||||||
|
|
||||||
// 如果选择过,则进行展示
|
// 如果选择过,则进行展示
|
||||||
let renderType = action === '卡片' ? 'card' : 'photo'
|
|
||||||
if (!e.isPoke) {
|
if (!e.isPoke) {
|
||||||
wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, [])
|
wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, [])
|
||||||
// 存在设置
|
// 存在设置
|
||||||
@ -127,7 +127,6 @@ export async function wife (e) {
|
|||||||
}
|
}
|
||||||
e.reply('在当前米游社公开展示的角色中未能找到适合展示的角色..')
|
e.reply('在当前米游社公开展示的角色中未能找到适合展示的角色..')
|
||||||
return true
|
return true
|
||||||
break
|
|
||||||
case '设置':
|
case '设置':
|
||||||
case '选择':
|
case '选择':
|
||||||
case '挑选':
|
case '挑选':
|
||||||
@ -139,7 +138,6 @@ export async function wife (e) {
|
|||||||
// 选择老婆
|
// 选择老婆
|
||||||
actionParam = actionParam.replace(/(,|、|;|;)/g, ',')
|
actionParam = actionParam.replace(/(,|、|;|;)/g, ',')
|
||||||
wifeList = actionParam.split(',')
|
wifeList = actionParam.split(',')
|
||||||
let addRet = []
|
|
||||||
if (lodash.intersection(['全部', '任意', '随机', '全都要'], wifeList).length > 0) {
|
if (lodash.intersection(['全部', '任意', '随机', '全都要'], wifeList).length > 0) {
|
||||||
addRet = ['随机']
|
addRet = ['随机']
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,14 +3,16 @@ import character from './character.js'
|
|||||||
import admin from './admin.js'
|
import admin from './admin.js'
|
||||||
import stat from './stat.js'
|
import stat from './stat.js'
|
||||||
import wiki from './wiki.js'
|
import wiki from './wiki.js'
|
||||||
|
import poke from './poke.js'
|
||||||
|
|
||||||
export const characterApp = character.v2App()
|
export const characterApp = character.v2App()
|
||||||
export const adminApp = admin.v2App()
|
export const adminApp = admin.v2App()
|
||||||
export const helpApp = help.v2App()
|
export const helpApp = help.v2App()
|
||||||
export const statApp = stat.v2App()
|
export const statApp = stat.v2App()
|
||||||
export const wikiApp = wiki.v2App()
|
export const wikiApp = wiki.v2App()
|
||||||
|
export const pokeApp = poke.v2App()
|
||||||
|
|
||||||
let apps = { character, admin, help, stat, wiki }
|
let apps = { character, admin, help, stat, wiki, poke }
|
||||||
let rule = {} // v2
|
let rule = {} // v2
|
||||||
let rules = {} // v3
|
let rules = {} // v3
|
||||||
for (let key in apps) {
|
for (let key in apps) {
|
||||||
|
14
apps/poke.js
Normal file
14
apps/poke.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { App } from '../components/index.js'
|
||||||
|
import { pokeWife } from './character/avatar-wife.js'
|
||||||
|
|
||||||
|
let app = App.init({
|
||||||
|
id: 'poke',
|
||||||
|
name: '角色查询',
|
||||||
|
event: 'poke'
|
||||||
|
})
|
||||||
|
|
||||||
|
app.reg('pock-wife', pokeWife, {
|
||||||
|
describe: '#老公 #老婆 查询'
|
||||||
|
})
|
||||||
|
|
||||||
|
export default app
|
@ -20,31 +20,37 @@ class App {
|
|||||||
v3App () {
|
v3App () {
|
||||||
let cfg = this.cfg || {}
|
let cfg = this.cfg || {}
|
||||||
let rules = []
|
let rules = []
|
||||||
|
let event = cfg.event
|
||||||
let cls = class extends plugin {
|
let cls = class extends plugin {
|
||||||
constructor () {
|
constructor () {
|
||||||
super({
|
super({
|
||||||
name: `喵喵:${cfg.name || cfg.id}`,
|
name: `喵喵:${cfg.name || cfg.id}`,
|
||||||
desc: cfg.desc || cfg.name || '喵喵插件',
|
dsc: cfg.desc || cfg.name || '喵喵插件',
|
||||||
event: 'message',
|
event: event === 'poke' ? 'notice.group.poke' : 'message',
|
||||||
priority: 50,
|
priority: 50,
|
||||||
rule: rules
|
rule: rules
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accept (e) {
|
||||||
|
e.original_msg = e.original_msg || e.msg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let key in this.apps) {
|
for (let key in this.apps) {
|
||||||
let app = this.apps[key]
|
let app = this.apps[key]
|
||||||
key = lodash.camelCase(key)
|
key = lodash.camelCase(key)
|
||||||
let rule = app.rule || app.reg || 'noCheck'
|
let rule = app.rule || app.reg || 'noCheck'
|
||||||
if (typeof (rule) === 'string') {
|
if (event !== 'poke') {
|
||||||
if (rule === '#poke#') {
|
if (typeof (rule) === 'string') {
|
||||||
continue
|
if (rule === 'noCheck') {
|
||||||
} else if (rule === 'noCheck') {
|
rule = '.*'
|
||||||
rule = '.+'
|
}
|
||||||
|
} else {
|
||||||
|
rule = lodash.trim(rule.toString(), '/')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rule = lodash.trim(rule.toString(), '/')
|
rule = '.*'
|
||||||
}
|
}
|
||||||
|
|
||||||
rules.push({
|
rules.push({
|
||||||
@ -54,6 +60,17 @@ class App {
|
|||||||
|
|
||||||
cls.prototype[key] = async function () {
|
cls.prototype[key] = async function () {
|
||||||
let e = this.e
|
let e = this.e
|
||||||
|
if (event === 'poke') {
|
||||||
|
console.log(e)
|
||||||
|
if (e.notice_type === 'group') {
|
||||||
|
if (e.user_id !== Bot.uin) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
e.user_id = e.operator_id
|
||||||
|
}
|
||||||
|
e.isPoke = true
|
||||||
|
e.msg = '#poke#'
|
||||||
|
}
|
||||||
e.original_msg = e.original_msg || e.msg
|
e.original_msg = e.original_msg || e.msg
|
||||||
e.checkAuth = e.checkAuth || async function (cfg) {
|
e.checkAuth = e.checkAuth || async function (cfg) {
|
||||||
return await checkAuth(e, cfg)
|
return await checkAuth(e, cfg)
|
||||||
|
Loading…
Reference in New Issue
Block a user