Skip to content

Commit

Permalink
feat: 添加聊天总结
Browse files Browse the repository at this point in the history
  • Loading branch information
leochen-g committed Jun 3, 2024
1 parent 245f2de commit bd787fc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-web-panel",
"version": "1.6.55",
"version": "1.6.56",
"description": "智能微秘书插件",
"exports": {
".": {
Expand Down
6 changes: 3 additions & 3 deletions src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ async function addReplyHistory(that, { content, contact, room }) {
const config = await allConfig()
const { role } = config.userInfo
if(role!=='vip') return
const robotInfo = that.currentUser
const userSelfName = robotInfo?.name() // 机器人名称
const userSelfId = robotInfo?.id // 机器人名称
const robotInfo = that?.currentUser || {}
const userSelfName = robotInfo?.name() || '' // 机器人名称
const userSelfId = robotInfo?.id || '' // 机器人名称

const contactName = contact?.name() // 接收消息人昵称
const contactId = contact?.id // 接收消息人id
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/on-record-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function onRecordMessage(msg) {
const type = msg.type()
const isOfficial = contact.type() === this.Contact.Type.Official
let content = ''
if (msgSelf || isOfficial || role !== 'vip') return
if (msgSelf || isOfficial || role !== 'vip' || !config.openRecord) return
switch (type) {
case this.Message.Type.Text:
case this.Message.Type.Url:
Expand Down
1 change: 1 addition & 0 deletions src/proxy/aibotk.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ async function getConfig() {
friendNoReplyInRoom: 0,
defaultReply: '',
forwards: [],
openRecord: false,
...config,
cloudRoom
})
Expand Down
5 changes: 3 additions & 2 deletions src/proxy/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ export async function getTXweather(city) {
let option = {
method: 'GET', url: 'tianqi', params: { city: city }
}
let todayInfo = await txReq(option)

const res = await txReq(option)
let todayInfo = res.list[0];
console.log('todayInfo', todayInfo)
let obj = {
weatherTips: todayInfo.tips,
todayWeather: `今天:${todayInfo.weather}${eol}温度:${todayInfo.lowest}/${todayInfo.highest}${eol}${todayInfo.wind} ${todayInfo.windspeed}${eol}${eol}`
Expand Down
22 changes: 14 additions & 8 deletions src/service/msg-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,22 @@ export async function summerChat({ that, msg, name, id, config, room, isMention,
histories = await getHistoryByNum({id: room ? roomId: id, name: room ? roomName: name }, item.summerNum)
}
let content = '';
for (const item of histories) {
if (item.content && item.content !== 'undefined' && item.content !== 'null' && item.content) {
content = `${content}\n对话时间:${dayjs.unix(item.time).format('YYYY-MM-DD HH:mm:ss')}:\n用户昵称:${item.chatName}:\n对话内容:${item.content}\n`;
if(histories.length) {
for (const item of histories) {
if (item.content && item.content !== 'undefined' && item.content !== 'null' && item.content) {
content = `${content}\n对话时间:${dayjs.unix(item.time).format('YYYY-MM-DD HH:mm:ss')}:\n用户昵称:${item.chatName}:\n对话内容:${item.content}\n`;
}
}
if(config.debug) {
console.log('获取到的聊天内容', content)
}
console.log('开始总结聊天内容')
const res = await dispatch.dispatchSummerBot({content, config: item, uid: room ? `${roomId}_${id}`: id})
return res;
} else {
console.log('没有获取到任何聊天记录内容,无法进行总结,请确认已经开启聊天记录')
return [{type: 1, content: ''}]
}
if(config.debug) {
console.log('获取到的聊天内容', content)
}
const res = await dispatch.dispatchSummerBot({content, config: item, uid: room ? `${roomId}_${id}`: id})
return res;
}

export { customBot }
Expand Down
4 changes: 2 additions & 2 deletions src/task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ async function sendCustomContent ({ that, target, type, item, isMulti, targets

if (!isMulti) {
for(const reply of contents) {
await contactSay(target, reply)
await contactSay.call(that, target, reply)
await delay(200)
}
} else {
for (let single of targets) {
try {
for(const reply of contents) {
type === 'room' ? await roomSay(single, '', reply): await contactSay(single, reply)
type === 'room' ? await roomSay.call(that, single, '', reply): await contactSay.call(that,single, reply)
await delay(200)
}
if (item.delay) {
Expand Down

0 comments on commit bd787fc

Please sign in to comment.