mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
Merge branch 'v2' into up
This commit is contained in:
commit
2eddff1a5d
2 changed files with 17 additions and 3 deletions
12
apps/bym.js
12
apps/bym.js
|
|
@ -16,6 +16,7 @@ import { EditCardTool } from '../utils/tools/EditCardTool.js'
|
||||||
import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
||||||
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
||||||
import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
||||||
|
import {SerpTool} from '../utils/tools/SerpTool.js'
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { fileTypeFromBuffer } from 'file-type';
|
import { fileTypeFromBuffer } from 'file-type';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
@ -131,7 +132,7 @@ export class bym extends plugin {
|
||||||
}
|
}
|
||||||
const picturesPath = pathModule.join(path, 'pictures');
|
const picturesPath = pathModule.join(path, 'pictures');
|
||||||
const fileImgList = await fs.promises.readdir(picturesPath);
|
const fileImgList = await fs.promises.readdir(picturesPath);
|
||||||
|
|
||||||
let ForRole = ALLRole
|
let ForRole = ALLRole
|
||||||
if (opt.image && !IsAtBot && !NotToImg && !e.at && Config.AutoToDownImg) {
|
if (opt.image && !IsAtBot && !NotToImg && !e.at && Config.AutoToDownImg) {
|
||||||
ALLRole = 'downimg'
|
ALLRole = 'downimg'
|
||||||
|
|
@ -163,6 +164,12 @@ export class bym extends plugin {
|
||||||
if (e.msg) {
|
if (e.msg) {
|
||||||
const originalMsg = e.msg;
|
const originalMsg = e.msg;
|
||||||
const replacedMsg = replaceUserInput(e.msg);
|
const replacedMsg = replaceUserInput(e.msg);
|
||||||
|
let fuck = false
|
||||||
|
let candidate = Config.bymPreset
|
||||||
|
if (Config.bymFuckList?.find(i => e.msg.includes(i))) {
|
||||||
|
fuck = true
|
||||||
|
candidate = candidate + Config.bymFuckPrompt
|
||||||
|
}
|
||||||
|
|
||||||
if (originalMsg !== replacedMsg) {
|
if (originalMsg !== replacedMsg) {
|
||||||
e.msg = replacedMsg;
|
e.msg = replacedMsg;
|
||||||
|
|
@ -275,6 +282,9 @@ export class bym extends plugin {
|
||||||
new WebsiteTool(),
|
new WebsiteTool(),
|
||||||
new WeatherTool()
|
new WeatherTool()
|
||||||
]
|
]
|
||||||
|
if (Config.azSerpKey) {
|
||||||
|
tools.push(new SerpTool())
|
||||||
|
}
|
||||||
if (e.group.is_admin || e.group.is_owner) {
|
if (e.group.is_admin || e.group.is_owner) {
|
||||||
tools.push(new EditCardTool())
|
tools.push(new EditCardTool())
|
||||||
tools.push(new JinyanTool())
|
tools.push(new JinyanTool())
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class EditCardTool extends AbstractTool {
|
||||||
description = 'Useful when you want to edit someone\'s card in the group(群名片)'
|
description = 'Useful when you want to edit someone\'s card in the group(群名片)'
|
||||||
|
|
||||||
func = async function (opts, e) {
|
func = async function (opts, e) {
|
||||||
let { qq, card, groupId } = opts
|
let { qq, card, groupId, isAdmin } = opts
|
||||||
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
|
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
|
||||||
groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim())
|
groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim())
|
||||||
|
|
||||||
|
|
@ -41,7 +41,11 @@ export class EditCardTool extends AbstractTool {
|
||||||
logger.error('获取群信息失败,可能使用的底层协议不完善')
|
logger.error('获取群信息失败,可能使用的底层协议不完善')
|
||||||
}
|
}
|
||||||
logger.info('edit card: ', groupId, qq)
|
logger.info('edit card: ', groupId, qq)
|
||||||
await group.setCard(qq, card)
|
if (isAdmin) {
|
||||||
|
await group.setCard(qq, card)
|
||||||
|
} else {
|
||||||
|
return 'the user is not admin, he can\'t edit card of other people.'
|
||||||
|
}
|
||||||
return `the user ${qq}'s card has been changed into ${card}`
|
return `the user ${qq}'s card has been changed into ${card}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue