forked from hanhan258/hanhan-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
475 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# 1.2.2 | ||
* 下架一些没用的功能,有啥想加的功能可以提issue | ||
# 1.2.1 | ||
* 加载日志显示版本号 | ||
# 1.1.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,68 @@ | ||
import fs from 'fs' | ||
import { segment } from 'icqq' | ||
// import fs from 'fs' | ||
// import { segment } from 'icqq' | ||
|
||
const RootPath = process.cwd() + '/plugins/hanhan-plugin/' | ||
// const RootPath = process.cwd() + '/plugins/hanhan-plugin/' | ||
export default class json extends plugin { | ||
constructor() { | ||
super({ | ||
name: '憨憨卡片', | ||
priority: 50, | ||
rule: [ | ||
{ | ||
reg: '#发红包$', | ||
fnc: 'hb' | ||
}, | ||
{ | ||
reg: '#fuck$', | ||
fnc: 'fuck' | ||
}, | ||
{ | ||
reg: '#卡片黑丝$', | ||
fnc: 'mv' | ||
}, | ||
{ | ||
reg: `#发送(.*)到`, | ||
fnc: 'sendMsdTOTargetGroup' | ||
}, | ||
{ | ||
reg: "^#(发送)json(消息|信息)?([\\s\\S]*)$", | ||
fnc: 'sendJson' | ||
} | ||
], | ||
}) | ||
} | ||
|
||
async sendJson(e) { | ||
let messag = e.msg; | ||
messag = messag.replace('#发送json', '') | ||
messag = messag.replace('消息', '') | ||
messag = messag.replace('信息', '') | ||
if (!messag) return; | ||
logger.info(messag) | ||
let msg = [{ type: 'json', data: `${messag}` }] | ||
this.reply(msg) | ||
return true; | ||
} | ||
|
||
async hb(e) { | ||
let json = this.getFileDataToJson('/resources/json/QQjson.json')['红包'] | ||
e.reply(segment.json(JSON.stringify(json))) | ||
} | ||
|
||
async mv(e) { | ||
let json = this.getFileDataToJson('/resources/json/QQjson.json')['卡片黑丝'] | ||
e.reply(segment.json(JSON.stringify(json))) | ||
} | ||
constructor () { | ||
super({ | ||
name: '憨憨卡片', | ||
priority: 50, | ||
rule: [ | ||
// { | ||
// reg: '#发送(.*)到', | ||
// fnc: 'sendMsdTOTargetGroup' | ||
// }, | ||
{ | ||
reg: '^#(发送)json(消息|信息)?([\\s\\S]*)$', | ||
fnc: 'sendJson' | ||
} | ||
] | ||
}) | ||
} | ||
|
||
async fuck(e) { | ||
let json = this.getFileDataToJson('/resources/json/QQjson.json')['fuck'] | ||
let msg = segment.json(JSON.stringify(json)) | ||
e.reply(msg) | ||
} | ||
async sendJson (e) { | ||
let message = e.msg | ||
message = message.replace('#发送json', '') | ||
message = message.replace('消息', '') | ||
message = message.replace('信息', '') | ||
if (!message) return | ||
logger.info(message) | ||
let msg = [{ type: 'json', data: `${message}` }] | ||
this.reply(msg) | ||
return true | ||
} | ||
|
||
//获取Json数据 | ||
getFileDataToJson(fileName, type = 'utf-8') { | ||
return JSON.parse(fs.readFileSync(RootPath + fileName, { encoding: type }) || null) | ||
} | ||
// 获取Json数据 | ||
// getFileDataToJson (fileName, type = 'utf-8') { | ||
// return JSON.parse(fs.readFileSync(RootPath + fileName, { encoding: type }) || null) | ||
// } | ||
|
||
//指定群发消息 | ||
async sendMsdTOTargetGroup(e) { | ||
let target = e.msg.replace(/#发送(.*)到/, '').trim() | ||
let key | ||
if (e.msg.includes('红包')) { | ||
key = '红包' | ||
} else if (e.msg.includes('黑丝')) { | ||
key = '卡片黑丝' | ||
} else if (e.msg.includes('fuck')) { | ||
key = 'fuck' | ||
} | ||
console.log(target) | ||
if (!target) return e.reply('你没有输入要发送的群聊') | ||
let groupList = await Bot.getGroupList() | ||
// console.log(groupList) | ||
console.log(groupList.get(target)) | ||
try { | ||
if (!groupList.has(target)) { | ||
let group = await Bot.pickGroup(target) | ||
let msg = segment.json(JSON.stringify(this.getFileDataToJson('/resources/json/QQjson.json')[`${key}`])) | ||
console.log(msg) | ||
await group.sendMsg(msg) | ||
e.reply('发送成功') | ||
} | ||
} catch (err) { | ||
return e.reply(`failed to send msg, error: ${JSON.stringify(err)}`) | ||
} | ||
} | ||
// 指定群发消息 | ||
// async sendMsdTOTargetGroup (e) { | ||
// let target = e.msg.replace(/#发送(.*)到/, '').trim() | ||
// let key | ||
// if (e.msg.includes('红包')) { | ||
// key = '红包' | ||
// } else if (e.msg.includes('黑丝')) { | ||
// key = '卡片黑丝' | ||
// } else if (e.msg.includes('fuck')) { | ||
// key = 'fuck' | ||
// } | ||
// console.log(target) | ||
// if (!target) return e.reply('你没有输入要发送的群聊') | ||
// let groupList = await Bot.getGroupList() | ||
// // console.log(groupList) | ||
// console.log(groupList.get(target)) | ||
// try { | ||
// if (!groupList.has(target)) { | ||
// let group = await Bot.pickGroup(target) | ||
// let msg = segment.json(JSON.stringify(this.getFileDataToJson('/resources/json/QQjson.json')[`${key}`])) | ||
// console.log(msg) | ||
// await group.sendMsg(msg) | ||
// e.reply('发送成功') | ||
// } | ||
// } catch (err) { | ||
// return e.reply(`failed to send msg, error: ${JSON.stringify(err)}`) | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.