Skip to content

Commit

Permalink
Lagrange 兼容 +1
Browse files Browse the repository at this point in the history
警告:此版本开始将不再支持 oicq 系 bot;如果你还在使用它们,请在 issue 告诉我
:sparkles: 对获取历史消息、获取表情进行了兼容
  • Loading branch information
Stapxs committed Mar 25, 2024
1 parent 8ab31a4 commit d2bd2e2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: build
on:
push: # push 触发
branches:
- main
- next

jobs:
# ========================= 准备项目 =========================
Expand All @@ -19,6 +19,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
persist-credentials: false
# 初始化一些流程需要的环境变量
- name: Init Env
Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
persist-credentials: false
# 设置 Node.js 版本
- name: Load Node.js
Expand Down Expand Up @@ -96,6 +98,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
persist-credentials: false
# 设置 Node.js 版本
- name: Load Node.js
Expand Down Expand Up @@ -159,4 +162,4 @@ jobs:
draft: false
prerelease: false
token: ${{ secrets.ACCESS_TOKEN }}


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stapxs-qq-lite",
"version": "2.6.0",
"version": "2.6.1",
"private": false,
"author": "Stapx Steve [林槐]",
"description": "一个兼容 oicq-http 的非官方网页版 QQ 客户端,使用 Vue 重制的全新版本。",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export default defineComponent({
// 从 Github 获取更新日志
const url = 'https://api.github.com/repos/stapxs/stapxs-qq-lite-2.0/commits'
const fetchData = {
sha: process.env.NODE_ENV == 'development' ? 'dev' : 'main',
sha: process.env.NODE_ENV == 'development' ? 'dev' : 'next',
per_page: '10'
} as Record<string, string>
fetch(url + '?' + new URLSearchParams(fetchData).toString())
Expand Down
8 changes: 7 additions & 1 deletion src/assets/pathMap/Lagrange.OneBot.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
"remark": "/user_remark"
}
},
"roaming_stamp": {
"_name": "fetch_custom_face"
},
"message_list": {
"_name": "get_history_msg",
"_name": "get_group_msg_history",
"_basic": "$.data.messages[*]",
"_type": "json_with_data|$.data",
"_message_type": {
Expand All @@ -39,6 +42,9 @@
"raw_message": "/raw_message"
}
},
"message_list_private": {
"_name": "get_friend_msg_history"
},
"message_info": {
"message_id": "$.message_id",
"private_id": "$.target_id",
Expand Down
2 changes: 1 addition & 1 deletion src/components/FacePan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default defineComponent({
mounted() {
// 加载漫游表情
if (runtimeData.stickerCache === undefined) {
Connector.send('get_roaming_stamp', {}, 'getRoamingStamp')
Connector.send(runtimeData.jsonMap.roaming_stamp._name, {}, 'getRoamingStamp')
}
}
})
Expand Down
26 changes: 22 additions & 4 deletions src/function/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ export function htmlDecodeByRegExp(str: string): string {

/**
* 根据区间和位数生成指定长度的随机数
* @param TODO: 我忘了这些参数都是干嘛的了,懒得看
* @returns 随机数组
* @param num 是否包含数字
* @param maxA 是否包含大写字母
* @param minlA 是否包含小写字母
* @param fqy 生成的随机数的位数
* @returns 生成的随机数字符串
*/
export function getRandom(num: boolean, maxA: boolean, minlA: boolean, fqy: number): string {
const arr = []
Expand Down Expand Up @@ -217,7 +220,14 @@ export function getMsgRawTxt(message: [{ [key: string]: any }]): string {
case 'record': back += '[语音]'; break
case 'video': back += '[视频]'; break
case 'file': back += '[文件]'; break
case 'json': back += JSON.parse(message[i].data).prompt; break
case 'json': {
try {
back += JSON.parse(message[i].data).prompt;
} catch (error) {
back += '[卡片消息]';
}
break
}
case 'xml': {
let name = message[i].data.substring(message[i].data.indexOf('<source name="') + 14)
name = name.substring(0, name.indexOf('"'))
Expand Down Expand Up @@ -378,13 +388,21 @@ export function loadHistory(info: BaseChatInfoElem) {
export function loadHistoryMessage(id: number, type: string, count = 20, echo = 'getChatHistoryFist') {
// 加载历史消息
// oicq2 Note: https://github.com/takayama-lily/oicq/wiki/93.%E8%A7%A3%E6%9E%90%E6%B6%88%E6%81%AFID
let name
if(runtimeData.jsonMap.message_list_private && type != "group") {
name = runtimeData.jsonMap.message_list_private._name
} else {
name = runtimeData.jsonMap.message_list._name
}

Connector.send(
runtimeData.jsonMap.message_list._name ?? 'get_chat_history',
name ?? 'get_chat_history',
{
message_type: runtimeData.jsonMap.message_list._message_type[type],
group_id: type == "group" ? id : undefined,
user_id: type != "group" ? id : undefined,
message_seq: 0,
message_id: 0,
count: count
},
echo
Expand Down
7 changes: 5 additions & 2 deletions src/utils/msgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ export function parseMsgList(list: any, map: string, valueMap: { [key: string]:
if(item.type == type) {
item[key] = jp.query(item, value as string)[0]
}
// 顺便把没用的 data 删了
delete item.data
// 顺便把没用的 data 删了,这边要注意 item.data 必须是个对象
// 因为有些消息类型的 data 就叫 data
if(typeof item.data == 'object') {
delete item.data
}
})
})
})
Expand Down

0 comments on commit d2bd2e2

Please sign in to comment.