Skip to content

Commit

Permalink
refactor: telecord -> yukihana
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Apr 24, 2024
1 parent 022466b commit 4d9ac8c
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
uses: actions/upload-artifact@v2.3.1
with:
# Artifact name
name: telecord-${{ matrix.ARCH }}.build
name: yukihana-${{ matrix.ARCH }}.build
path: tmp/build

upload:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v1.1.2 / 2024-04-
## v1.1.2 / 2024-04-24

- refactor: 重构websocket的action处理
- feat: 基础信息获取,好友/群/群成员
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM msojocs/telecord:v3.2.5-21453
FROM msojocs/yukihana:v3.2.5-21453

COPY ./ntqq/resources/app/app_launcher/index.js /opt/qq/resources/app/app_launcher/index.js
COPY ./ntqq/resources/app/app_launcher/core.jsc /opt/qq/resources/app/app_launcher/core.jsc
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
services:
telecord:
yukihana:
build:
context: .
dockerfile: Dockerfile
tty: true
container_name: telecord
container_name: yukihana
restart: always
ports:
- "8080:8080"
Expand Down
2 changes: 1 addition & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

大致结构如下:
```
Telecord
Yukihana
├─ntqq
│ ├─lib
│ ├─locales
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telecord",
"version": "1.2.0",
"name": "yukihana",
"version": "1.1.2",
"description": "",
"type": "module",
"main": "index.js",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Telecord
# Yukihana

基于 Telecord 的机器人框架
基于 Yukihana 的机器人框架

## 实现的功能

Expand Down
58 changes: 29 additions & 29 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,37 @@ const options: RollupOptions[] = [
typescript(),
json(),
// 压缩
// terser(),
// // 混淆
// obfuscator({
// global: true,
// }),
// {
// name: 'jsc',
// writeBundle: (options, bundle) => {
// console.log('generate jsc...')
// if (bundle['core.js']) {
// const core = bundle['core.js']
// // console.log(options)
// if (core.type === 'chunk' && options.dir) {
// const fromPath = path.resolve(options.dir, './core.js')
// console.log('compile file:', fromPath)
// // 字节码生成
// bytenode.compileFile({
// filename: fromPath,
// compileAsModule: true,
// electron: true,
// compress: true,
// electronPath: process.env['PROGRAM_PATH'],
// output: `${fromPath}c`,
// })
// }
// }
// }
// },
terser(),
// 混淆
obfuscator({
global: true,
}),
{
name: 'jsc',
writeBundle: (options, bundle) => {
console.log('generate jsc...')
if (bundle['core.js']) {
const core = bundle['core.js']
// console.log(options)
if (core.type === 'chunk' && options.dir) {
const fromPath = path.resolve(options.dir, './core.js')
console.log('compile file:', fromPath)
// 字节码生成
bytenode.compileFile({
filename: fromPath,
compileAsModule: true,
electron: true,
compress: true,
electronPath: process.env['PROGRAM_PATH'],
output: `${fromPath}c`,
})
}
}
}
},
],
// 指出哪些模块应该视为外部模块
external: ['electron', 'module', 'ntwrapper', 'telecord-native'],
external: ['electron', 'module', 'ntwrapper', 'yukihana-native'],
},
{
input: 'src/index.ts',
Expand Down
4 changes: 2 additions & 2 deletions src/http/group/upload-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export const uploadFile = (req: Request, res: Response, next: NextFunction) => {
const ext = mimeType2Extension(file.mimetype)
file.mv(`${realPath}/${file.md5}${ext}`)
const cfg = getConfig()
let host = cfg.telecord.http.host
let host = cfg.yukihana.http.host
if (host === '0.0.0.0') {
host = '127.0.0.1'
}
res.json({
path: `${realPath}/${file.md5}${ext}`,
url: `http://${host}:${cfg.telecord.http.port}/static/${p}/${file.md5}${ext}`,
url: `http://${host}:${cfg.yukihana.http.port}/static/${p}/${file.md5}${ext}`,
md5: file.md5,
size: file.size,
})
Expand Down
4 changes: 2 additions & 2 deletions src/native/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { install } from 'telecord-native'
import { install } from 'yukihana-native'
import { useConfigStore } from '../store/config'
import { useLogger } from '../common/log'

Expand All @@ -7,7 +7,7 @@ export const initNative = () => {
// 获取函数签名
const { getSignature } = useConfigStore()
const sig = getSignature()
const sigData: TelecordNativeWrapper.SignatureType = {}
const sigData: YukihanaNativeWrapper.SignatureType = {}

if (sig?.sqlite3_stmt) {
const signature = sig?.sqlite3_stmt
Expand Down
6 changes: 3 additions & 3 deletions src/ntqq/types/native.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="node" />

declare namespace TelecordNativeWrapper {
declare namespace YukihanaNativeWrapper {
namespace CrossProcessExports {
/**
* 模块安装
Expand Down Expand Up @@ -93,7 +93,7 @@ declare namespace TelecordNativeWrapper {
}
}

declare module 'telecord-native' {
export = TelecordNativeWrapper.CrossProcessExports
declare module 'yukihana-native' {
export = YukihanaNativeWrapper.CrossProcessExports
}

2 changes: 1 addition & 1 deletion src/onebot/actions/message/send_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { sendForwardMessageToGroup, sendMessageToGroup } from "../../../transfer
import { BotMessage } from "../../common/message"
import { getBotAccount } from "../../common/user"
import { BotActionResponse } from "../interfaces"
import { addMsg } from 'telecord-native'
import { addMsg } from 'yukihana-native'

const log = useLogger('ActionGroup')
const sendMessage = async (p: BotMessage.SendMsg): Promise<any> => {
Expand Down
8 changes: 4 additions & 4 deletions src/onebot/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

## Actions目录

用于bot与telecord通信
用于bot与yukihana通信

1. bot(client) -> telecord [request]
2. bot(client) <- telecord [response]
1. bot(client) -> yukihana [request]
2. bot(client) <- yukihana [response]

## Event目录

机器人事件下发(单向)

NTQQ -> telecord -> bot(client)
NTQQ -> yukihana -> bot(client)
2 changes: 1 addition & 1 deletion src/server/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const startHTTPServer = () => {
cert: readFileSync(resolve(__dirname, './server.crt'))
};
const httpServer = createServer(app)
httpServer.listen(cfg.telecord.http.port, cfg.telecord.http.host)
httpServer.listen(cfg.yukihana.http.port, cfg.yukihana.http.host)
const httpsServer = https.createServer(options, app)
log.info('Try to listen on 443.')
httpsServer.listen(443)
Expand Down
4 changes: 2 additions & 2 deletions src/server/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const startWebsocketServer = () => {
const { getConfig } = useConfigStore()
const cfg = getConfig()
const wss = new WebSocketServer({
host: cfg.telecord.ws.host,
port: cfg.telecord.ws.port,
host: cfg.yukihana.ws.host,
port: cfg.yukihana.ws.port,
});

wss.on('connection', function connection(ws) {
Expand Down
4 changes: 2 additions & 2 deletions src/store/config-type.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface TelecordConfig {
telecord: {
export interface YukihanaConfig {
yukihana: {
profiles: {
active: string
}
Expand Down
20 changes: 10 additions & 10 deletions src/store/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { existsSync, readFileSync } from "fs"
import yaml from 'yaml'
import { TelecordConfig } from "./config-type"
import { YukihanaConfig } from "./config-type"
import { getNTPackageInfo } from "../ntqq/common/utils"
import { useLogger } from "../common/log"
import { resolve } from "path"

let configCache: TelecordConfig = {
telecord: {
let configCache: YukihanaConfig = {
yukihana: {
profiles: {
active: 'prod',
},
Expand All @@ -26,7 +26,7 @@ let configCache: TelecordConfig = {
}
}
let inited: boolean = false
const log = useLogger('Telecord Config')
const log = useLogger('Yukihana Config')

/**
* 从文件加载配置
Expand All @@ -35,14 +35,14 @@ const log = useLogger('Telecord Config')
*/
const loadFromFile = () => {
log.info('loadFromFile')
const cfg = readFileSync(resolve(__dirname, './telecord.yaml')).toString()
let defaultConfig = yaml.parse(cfg) as TelecordConfig
const cfg = readFileSync(resolve(__dirname, './yukihana.yaml')).toString()
let defaultConfig = yaml.parse(cfg) as YukihanaConfig
log.info('cfg data:', defaultConfig)
{
const localPath = resolve(__dirname, './telecord.local.yaml')
const localPath = resolve(__dirname, './yukihana.local.yaml')
if (existsSync(localPath)) {
const localCfg = readFileSync(localPath).toString()
const localConfig = yaml.parse(localCfg) as TelecordConfig
const localConfig = yaml.parse(localCfg) as YukihanaConfig
defaultConfig = {
...defaultConfig,
...localConfig,
Expand Down Expand Up @@ -78,11 +78,11 @@ const getSignature = () => {
const pkg = getNTPackageInfo()
const cfg = getConfig()
if (process.platform === 'linux' || process.platform === 'win32')
return cfg.telecord.signature[process.platform][pkg.version]
return cfg.yukihana.signature[process.platform][pkg.version]
}
const getStoragePath = () => {
const cfg = getConfig()
return resolve(__dirname, cfg.telecord['storage-path'])
return resolve(__dirname, cfg.yukihana['storage-path'])
}
export const useConfigStore = () => ({
/**
Expand Down
8 changes: 4 additions & 4 deletions src/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ScriptHook extends Script{
log.info('length:', code?.length, options?.cachedData?.length)
if (options) {
log.info('cachedData:', options.cachedData?.toString())
fs.writeFileSync(`D:\\GitHub\\Telecord\\tmp\\start.code`, options.cachedData)
fs.writeFileSync(`D:\\GitHub\\Yukihana\\tmp\\start.code`, options.cachedData)
}
}
runInContext(obj: any, options?: any) {
Expand Down Expand Up @@ -372,8 +372,8 @@ const hookAsync = () => {
}
const vmTest = () => {
let codeTarget = 1
const config = JSON.parse(fs.readFileSync(`D:\\GitHub\\Telecord\\tmp\\bytecode\\start${codeTarget}.json`).toString())
const byteCode = fs.readFileSync(`D:\\GitHub\\Telecord\\tmp\\bytecode\\start${codeTarget}.jsc`)
const config = JSON.parse(fs.readFileSync(`D:\\GitHub\\Yukihana\\tmp\\bytecode\\start${codeTarget}.json`).toString())
const byteCode = fs.readFileSync(`D:\\GitHub\\Yukihana\\tmp\\bytecode\\start${codeTarget}.jsc`)
log.info('start with:', config.filename)
// bytenode.runBytecode(code)
v8.setFlagsFromString('--no-lazy')
Expand Down Expand Up @@ -486,7 +486,7 @@ const vmTest = () => {
// 'multiInstancePort': function(){}
// })
// const f = script.runInNewContext(ctx, {
// filename: 'D:\\GitHub\\Telecord\\ntqq\\resources\\app\\versions\\9.9.7-21357\\app_launcher\\index.js',
// filename: 'D:\\GitHub\\Yukihana\\ntqq\\resources\\app\\versions\\9.9.7-21357\\app_launcher\\index.js',
// lineOffset: 0,
// columnOffset: 0,
// displayErrors: true,
Expand Down
4 changes: 2 additions & 2 deletions src/transfer/message/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { convertBotMessage2NTInnerMessage, convertBotMessage2NTMessage } from ".
import { BotMessage, BotMessageSendElements } from "../../onebot/common/message"
import { useNTCore } from "../../ntqq/core/core"
import { getBotAccount } from "../../onebot/common/user"
import { addMsg } from "telecord-native"
import { addMsg } from "yukihana-native"

const log = useLogger('Group')

Expand Down Expand Up @@ -81,7 +81,7 @@ export const sendForwardMessageToGroup = async (targetId: `${number}`, msg: BotM
log.info('use random msgId:', msgId)
// 转换为可添加的消息
try {
const msgContent: TelecordNativeWrapper.AddMsgType = {
const msgContent: YukihanaNativeWrapper.AddMsgType = {
msgId: msgId,
msgRandom: Math.floor(Math.random() * 10e5),
msgSeq: 10000 + i,
Expand Down
Loading

0 comments on commit 4d9ac8c

Please sign in to comment.