├── output ├── preload │ └── index.js ├── renderer │ └── index.js └── main │ └── index.js ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── new-feature.yaml │ └── bug-report.yaml └── workflows │ └── auto-build.yml ├── changeLog.md ├── .gitignore ├── src ├── workers │ └── interval.js ├── utils │ ├── timeMode.ts │ ├── modifyTargets.ts │ ├── config.ts │ ├── getGroupTargets.ts │ ├── parseMsg.ts │ ├── sendMsgEntry.ts │ ├── sendMsg.ts │ └── checkTime.ts ├── preload │ └── index.ts ├── config │ └── config.ts ├── main │ └── index.ts ├── global.d.ts ├── renderer │ └── index.ts └── pages │ └── settings.html ├── LiteLoaderQQNT-Euphony ├── src │ ├── assets │ │ ├── html │ │ │ └── chat_func_bar_button.html │ │ └── css │ │ │ └── chat_func_bar.css │ ├── main │ │ ├── main.js │ │ ├── renderer.js │ │ └── preload.js │ ├── message │ │ ├── content │ │ │ ├── raw.js │ │ │ ├── plain_text.js │ │ │ ├── at_all.js │ │ │ ├── at.js │ │ │ ├── image.js │ │ │ └── audio.js │ │ ├── message_source.js │ │ ├── single_message.js │ │ └── message_chain.js │ ├── index.js │ ├── cache │ │ └── cache.js │ ├── client │ │ ├── client.js │ │ └── ui │ │ │ └── chat_func_bar.js │ ├── contact │ │ ├── contact.js │ │ ├── friend.js │ │ ├── group.js │ │ └── member.js │ └── event │ │ └── event_channel.js └── manifest.json ├── assets └── icon.svg ├── tsconfig.json ├── tutoril.md ├── tsconfig.web.json ├── tsconfig.node.json ├── CONTRIBUTING.md ├── package.json ├── manifest.json ├── eslint.config.mjs ├── README.md ├── electron.vite.config.ts └── LICENSE /output/preload/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /output/renderer/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /changeLog.md: -------------------------------------------------------------------------------- 1 | 1. 使用Workers以减轻QQ休眠对定时器的影响(#13) 2 | 2. 独立配置文件(#12) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | *.zip 4 | .eslintcache 5 | -------------------------------------------------------------------------------- /output/main/index.js: -------------------------------------------------------------------------------- 1 | throw new Error('你正在使用源码包,请卸载该插件,并使用Release包重新安装!'); -------------------------------------------------------------------------------- /src/workers/interval.js: -------------------------------------------------------------------------------- 1 | onmessage = () => { 2 | setInterval(() => { 3 | postMessage('checkTime'); 4 | }, 60000); 5 | }; -------------------------------------------------------------------------------- /src/utils/timeMode.ts: -------------------------------------------------------------------------------- 1 | export default (time: string): 'exactly' | 'per' => { 2 | if(time.includes(':')) return 'exactly'; 3 | else return 'per'; 4 | }; -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/assets/html/chat_func_bar_button.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
-------------------------------------------------------------------------------- /assets/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.node.json" }, 5 | { "path": "./tsconfig.web.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /tutoril.md: -------------------------------------------------------------------------------- 1 | # 高级语法 2 | 3 | ## 介绍 4 | 使用部分高级语法满足需求。 5 | 6 | 高级语法满足以下的基本格式: 7 | 8 | `%语法名%{语法参数}` 9 | 10 | ## At 11 | 格式:%At%{QQ号} 12 | 13 | 例:测试%At%{123456789} -------------------------------------------------------------------------------- /tsconfig.web.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@electron-toolkit/tsconfig/tsconfig.web.json", 3 | "include": ["src/**/*.ts", "src/**/*.d.ts"], 4 | "compilerOptions": { 5 | "composite": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@electron-toolkit/tsconfig/tsconfig.node.json", 3 | "include": ["electron.vite.config.*", "src/**/*.ts", "src/**/*.d.ts"], 4 | "compilerOptions": { 5 | "composite": true, 6 | "types": ["electron-vite/node"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/assets/css/chat_func_bar.css: -------------------------------------------------------------------------------- 1 | .chat-func-bar-button { 2 | display: flex; 3 | margin: 0px 8px; 4 | align-items: center; 5 | } 6 | 7 | .chat-func-bar-button-icon { 8 | width: 24px; 9 | height: 24px; 10 | } 11 | 12 | .chat-func-bar-button-icon:hover { 13 | color: #0099FF; 14 | } -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/main/main.js: -------------------------------------------------------------------------------- 1 | exports.onBrowserWindowCreated = window => { 2 | window.webContents.on('ipc-message-sync', (event, channel) => { 3 | if (channel == '___!boot') { 4 | event.returnValue = { 5 | enabled: true, 6 | webContentsId: window.webContents.id.toString(), 7 | }; 8 | } 9 | }); 10 | } -------------------------------------------------------------------------------- /src/utils/modifyTargets.ts: -------------------------------------------------------------------------------- 1 | import { readConfig, writeConfig } from './config'; 2 | import getGroupTargets from './getGroupTargets'; 3 | 4 | export default async () => { 5 | let currentConfig = await readConfig(await LLASM.getUid()); 6 | 7 | const targets = getGroupTargets(currentConfig); 8 | currentConfig.targets = targets; 9 | writeConfig(await LLASM.getUid(), currentConfig); 10 | }; -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-feature.yaml: -------------------------------------------------------------------------------- 1 | name: 优化提议 2 | description: 对已有功能进行增强或调整 3 | title: '[Feat]: ' 4 | labels: [ "enhancement" ] 5 | 6 | body: 7 | - type: textarea 8 | id: feature-to-add 9 | attributes: 10 | label: 需要调整的功能内容 11 | description: | 12 | 请想调整的功能,包括实现的模拟(如有) 13 | 是否有类似的功能已经实现?如有请提出与该功能不同的地方/想改进该功能的哪一部分。 14 | validations: 15 | required: true 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 贡献指南 2 | 3 | 本指南用于给想要给本项目贡献代码的开发者一些帮助。 4 | 5 | ## 项目介绍 6 | 7 | 本项目为`LiteLoaderQQNT`框架的一个插件。 8 | 9 | 本项目使用TS+Electron+Vite编写,你需要对这些库有基础的了解。 10 | 11 | ## PR准则 12 | 13 | 1. 详细描述该PR的作用(或修复的bug),如果对应某个Issue,则应附带该Issue的编号。 14 | 2. 本项目使用TS,所以请使用TS贡献你的代码。 15 | 3. 所有PR均有权被维护者关闭,但原则上会给出关闭说明。(如果没有,请反思你的PR是否符合这里给出的准则,以及你的修改是否合理) 16 | 4. 本准则会根据实际增加、删除、修改条目,请密切留意。 17 | 18 | ## 适用范围 19 | 20 | 本贡献指南适用于仓库所有者的所有`LiteLoaderQQNT`插件。 -------------------------------------------------------------------------------- /src/utils/config.ts: -------------------------------------------------------------------------------- 1 | import { ISettingConfig } from '../config/config'; 2 | 3 | export const readConfig = async (uid: string): Promise => { 4 | const dataPath = LiteLoader.plugins.auto_send_messages.path.data; 5 | 6 | const config: ISettingConfig = await (await fetch(`local:///${dataPath}/${uid}.json`)).json(); 7 | 8 | return config; 9 | }; 10 | 11 | export const writeConfig = (uid: string, config: ISettingConfig) => { 12 | LLASM.writeConfig(uid, config); 13 | }; -------------------------------------------------------------------------------- /src/utils/getGroupTargets.ts: -------------------------------------------------------------------------------- 1 | import { ISettingConfig } from '../config/config'; 2 | import { Client, Group } from '../../LiteLoaderQQNT-Euphony/src'; 3 | 4 | export default (currentConfig: ISettingConfig): string[] => { 5 | let targets: string[] = []; 6 | if(currentConfig.mode == 'black'){ 7 | const allGroups: Group[] = Client.getGroups(); 8 | for(const g of allGroups){ 9 | if(!currentConfig.groups.includes(g.getId())) targets.push(g.getId()); 10 | } 11 | } 12 | else targets = currentConfig.groups; 13 | 14 | return targets; 15 | }; -------------------------------------------------------------------------------- /src/preload/index.ts: -------------------------------------------------------------------------------- 1 | import { contextBridge, ipcRenderer } from 'electron'; 2 | import { ISettingConfig } from '../config/config'; 3 | 4 | contextBridge.exposeInMainWorld('LLASM', { 5 | openFileDialog: (type: 'chats' | 'groups', uid: string) => { 6 | ipcRenderer.send('LLASM.openFileDialog', type, uid); 7 | }, 8 | onLogin: (callback: () => void) => { 9 | ipcRenderer.on('LLASM.onLogin', callback); 10 | }, 11 | writeConfig: (uid: string, config: ISettingConfig) => { 12 | ipcRenderer.send('LLASM.writeConfig', uid, config); 13 | }, 14 | getUid: (): Promise => ipcRenderer.invoke('LLASM.getUid'), 15 | }); -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 4, 3 | "type": "framework", 4 | "name": "Euphony", 5 | "slug": "euphony", 6 | "description": "一个为LiteLoaderQQNT插件提供基础功能的依赖", 7 | "version": "1.1.0", 8 | "authors": [{ 9 | "name": "xtaw", 10 | "link": "https://github.com/xtaw" 11 | }], 12 | "repository": { 13 | "repo": "xtaw/LiteLoaderQQNT-Euphony", 14 | "branch": "master" 15 | }, 16 | "platform": ["win32", "linux", "darwin"], 17 | "injects": { 18 | "renderer": "./src/main/renderer.js", 19 | "main": "./src/main/main.js", 20 | "preload": "./src/main/preload.js" 21 | } 22 | } -------------------------------------------------------------------------------- /src/utils/parseMsg.ts: -------------------------------------------------------------------------------- 1 | import { MessageChain, PlainText, At } from '../../LiteLoaderQQNT-Euphony/src'; 2 | 3 | export default (msg: string): MessageChain => { 4 | const parseRegex = new RegExp(/%At%{[0-9]+}/g); 5 | const getUin = new RegExp(/[0-9]+/g); 6 | const searchResult = msg.matchAll(parseRegex); 7 | const messagesSplitedArray = msg.split(parseRegex); 8 | let messageChain: MessageChain = new MessageChain(); 9 | 10 | messageChain.append(new PlainText(messagesSplitedArray[0])); 11 | let index = 1; 12 | for(const eachResult of searchResult){ 13 | const uin = eachResult[0].match(getUin); 14 | messageChain.append(At.fromUin(uin![0])).append(new PlainText(messagesSplitedArray[index])); 15 | index++; 16 | } 17 | 18 | return messageChain; 19 | }; -------------------------------------------------------------------------------- /src/utils/sendMsgEntry.ts: -------------------------------------------------------------------------------- 1 | import dayjs from 'dayjs'; 2 | import customParseFormat from 'dayjs/plugin/customParseFormat'; 3 | import { ISettingConfig } from '../config/config'; 4 | import sendMsg from './sendMsg'; 5 | import { writeConfig } from './config'; 6 | 7 | export default async (currentConfig: ISettingConfig, targets: string[]) => { 8 | dayjs.extend(customParseFormat); 9 | 10 | sendMsg('groups', targets, currentConfig.messages.groups, currentConfig.pictures.groups); 11 | 12 | sendMsg('chats', currentConfig.chats, currentConfig.messages.chats, currentConfig.pictures.chats); 13 | 14 | currentConfig.isAct = true; 15 | currentConfig.lastActTime = `${dayjs().get('hour').toString()}:${dayjs().get('minute').toString()}`; 16 | writeConfig(await LLASM.getUid(), currentConfig); 17 | }; -------------------------------------------------------------------------------- /src/config/config.ts: -------------------------------------------------------------------------------- 1 | export const config: ISettingConfig = { 2 | mode: 'white', 3 | messages: { 4 | groups: '', 5 | chats: '', 6 | }, 7 | pictures: { 8 | groups: '', 9 | chats: '', 10 | }, 11 | groups: [], 12 | targets: [], 13 | chats: [], 14 | sendTime: '', 15 | lastActTime: '', 16 | isAct: false, 17 | }; 18 | 19 | export interface ISettingMessageConfig { 20 | groups: string; 21 | 22 | chats: string; 23 | }; 24 | 25 | export interface ISettingConfig { 26 | mode: 'black' | 'white'; 27 | 28 | messages: ISettingMessageConfig; 29 | 30 | pictures: ISettingMessageConfig; 31 | 32 | groups: string[]; 33 | 34 | targets: string[]; 35 | 36 | chats: string[]; 37 | 38 | sendTime: string; 39 | 40 | lastActTime: string; 41 | 42 | isAct: boolean; 43 | }; -------------------------------------------------------------------------------- /src/utils/sendMsg.ts: -------------------------------------------------------------------------------- 1 | import { Group, Friend, Image } from '../../LiteLoaderQQNT-Euphony/src'; 2 | import parseMsg from './parseMsg'; 3 | 4 | export default (type: 'groups' | 'chats', targets: string[], msg: string, picture: string) => { 5 | if(type == 'groups'){ 6 | targets.forEach((g) => { 7 | const group = Group.make(g); 8 | const messageChain = parseMsg(msg); 9 | if(picture) messageChain.append(new Image(picture)); 10 | setTimeout(() => group.sendMessage(messageChain), 2000 * Math.random()); 11 | }); 12 | } 13 | else{ 14 | targets.forEach((c) => { 15 | const friend = Friend.fromUin(c); 16 | const messageChain = parseMsg(msg); 17 | if(picture) messageChain.append(new Image(picture)); 18 | setTimeout(() => friend.sendMessage(messageChain), 2000 * Math.random()); 19 | }); 20 | } 21 | }; -------------------------------------------------------------------------------- /.github/workflows/auto-build.yml: -------------------------------------------------------------------------------- 1 | name: auto-build 2 | on: 3 | push: 4 | tags: 5 | - "v*" 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | 10 | permissions: 11 | contents: write 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Set up Nodejs 18 | uses: actions/setup-node@v4 19 | with: 20 | node-version: 20 21 | 22 | - uses: pnpm/action-setup@v3 23 | 24 | - name: build 25 | run: | 26 | pnpm install 27 | pnpm build 28 | 29 | - name: Create Release 30 | id: create_release 31 | uses: softprops/action-gh-release@v2 32 | if: startsWith(github.ref, 'refs/tags/') 33 | with: 34 | files: auto_send_messages.zip 35 | body_path: ./changeLog.md 36 | -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/raw.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from "../../index.js"; 2 | 3 | /** 4 | * `Raw` 类型代表一个原生消息元素,所有暂不受支持的消息类型均会被处理为该类型。 5 | * 6 | * @property { Native } #element 原生消息元素。 7 | */ 8 | class Raw extends SingleMessage { 9 | 10 | #element; 11 | 12 | /** 13 | * 构造一个代表 `element` 的原生消息元素。 14 | * 15 | * @param { Native } element 原生消息元素。 16 | */ 17 | constructor(element) { 18 | super(); 19 | this.#element = element; 20 | } 21 | 22 | /** 23 | * 返回该消息元素的 `#element` 属性。 24 | * 25 | * @returns { Native } 该消息元素的 `#element` 属性。 26 | */ 27 | getElement() { 28 | return this.#element; 29 | } 30 | 31 | /** 32 | * 返回该消息元素所对应的 **element** 对象。 33 | * 34 | * @returns { Native } 该消息元素所对应的 **element** 对象。 35 | */ 36 | async toElement() { 37 | return this.#element; 38 | } 39 | 40 | } 41 | 42 | export default Raw -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/main/renderer.js: -------------------------------------------------------------------------------- 1 | import { Contact, Friend, Group, Member, SingleMessage, MessageChain, MessageSource, PlainText, Image, Audio, At, AtAll, Raw, EventChannel, Client, Cache, ChatFuncBar } from '../index.js'; 2 | 3 | const chatFuncBarCss = document.createElement('link'); 4 | chatFuncBarCss.rel = 'stylesheet'; 5 | chatFuncBarCss.href = `local:///${ LiteLoader.plugins['euphony'].path.plugin }/src/assets/css/chat_func_bar.css`; 6 | document.head.appendChild(chatFuncBarCss); 7 | 8 | Object.defineProperty(window, 'euphony', { 9 | value: { 10 | Contact, 11 | Friend, 12 | Group, 13 | Member, 14 | SingleMessage, 15 | MessageChain, 16 | MessageSource, 17 | PlainText, 18 | Image, 19 | Audio, 20 | At, 21 | AtAll, 22 | Raw, 23 | EventChannel, 24 | Client, 25 | Cache, 26 | ChatFuncBar 27 | }, 28 | writable: false 29 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "liteloaderqqnt-auto-send-messages", 3 | "version": "1.7.0", 4 | "description": "A plugin for LiteLoaderQQNT. It can auto send messages to the groups. It is powered by Vite & Typescript", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "lint": "eslint --cache --fix ./src/**/*.{js,cjs,mjs,ts,jsx,tsx}", 9 | "build": "electron-vite build" 10 | }, 11 | "author": "Adpro", 12 | "license": "GPL-3.0-only", 13 | "devDependencies": { 14 | "@electron-toolkit/eslint-config-ts": "^2.0.0", 15 | "@electron-toolkit/tsconfig": "^1.0.1", 16 | "@typescript-eslint/eslint-plugin": "8.5.0", 17 | "@typescript-eslint/parser": "8.5.0", 18 | "electron": "^32.1.0", 19 | "electron-vite": "^2.3.0", 20 | "eslint": "^9.10.0", 21 | "unplugin-zip-pack": "1.0.3-beta.0", 22 | "vite": "^5.4.5", 23 | "vite-plugin-checker": "^0.8.0", 24 | "vite-plugin-cp": "^4.0.8" 25 | }, 26 | "dependencies": { 27 | "dayjs": "^1.11.13" 28 | }, 29 | "packageManager": "pnpm@9.9.0" 30 | } 31 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/adproqwq/LiteLoaderQQNT-Manifest-JsonSchema/main/manifest.schema.json", 3 | "manifest_version": 4, 4 | "type": "extension", 5 | "name": "定时消息", 6 | "slug": "auto_send_messages", 7 | "description": "定时自动发送消息,允许定时发送、定群发送、自定义消息内容", 8 | "version": "1.7.0", 9 | "icon": "./assets/icon.svg", 10 | "thumb": "./assets/icon.svg", 11 | "authors": [ 12 | { 13 | "name": "Adpro", 14 | "link": "https://github.com/adproqwq" 15 | } 16 | ], 17 | "platform": [ 18 | "win32", 19 | "linux", 20 | "darwin" 21 | ], 22 | "dependencies": [ 23 | "euphony", 24 | "LiteLoaderQQNT_CheckUpdateModule" 25 | ], 26 | "injects": { 27 | "main": "./output/main/index.js", 28 | "preload": "./output/preload/index.js", 29 | "renderer": "./output/renderer/index.js" 30 | }, 31 | "repository": { 32 | "repo": "adproqwq/LiteLoaderQQNT-AutoSendMessages", 33 | "branch": "main", 34 | "release": { 35 | "tag": "v1.7.0", 36 | "file": "auto_send_messages.zip" 37 | } 38 | }, 39 | "PIinstall": false 40 | } -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { FlatCompat } from '@eslint/eslintrc'; 2 | import path from 'path'; 3 | import { fileURLToPath } from 'url'; 4 | import typescriptEslint from '@typescript-eslint/eslint-plugin'; 5 | import typescriptEslintParser from '@typescript-eslint/parser'; 6 | 7 | const __filename = fileURLToPath(import.meta.url); 8 | const __dirname = path.dirname(__filename); 9 | 10 | const compat = new FlatCompat({ 11 | baseDirectory: __dirname, 12 | }); 13 | 14 | export default [ 15 | ...compat.extends('plugin:@typescript-eslint/recommended'), 16 | { 17 | plugins: { 18 | typescriptEslint: typescriptEslint, 19 | }, 20 | languageOptions: { 21 | parser: typescriptEslintParser, 22 | }, 23 | rules: { 24 | '@typescript-eslint/ban-ts-comment': 'off', 25 | '@typescript-eslint/no-empty-function': 'off', 26 | '@typescript-eslint/no-unused-vars': 'off', 27 | '@typescript-eslint/no-non-null-assertion': 'off', 28 | '@typescript-eslint/no-explicit-any': 'off', 29 | 'no-empty': 'off', 30 | 'prefer-const': 'off', 31 | quotes: ['error', 'single', { allowTemplateLiterals: false }], 32 | }, 33 | ignores: ['dist/*'], 34 | }, 35 | ]; 36 | -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/index.js: -------------------------------------------------------------------------------- 1 | import Contact from './contact/contact.js'; 2 | import Friend from './contact/friend.js'; 3 | import Group from './contact/group.js'; 4 | import Member from './contact/member.js'; 5 | 6 | import SingleMessage from './message/single_message.js'; 7 | import MessageChain from './message/message_chain.js'; 8 | import MessageSource from './message/message_source.js'; 9 | 10 | import PlainText from './message/content/plain_text.js'; 11 | import Image from './message/content/image.js'; 12 | import Audio from './message/content/audio.js'; 13 | import At from './message/content/at.js'; 14 | import AtAll from './message/content/at_all.js'; 15 | import Raw from './message/content/raw.js'; 16 | 17 | import EventChannel from './event/event_channel.js'; 18 | 19 | import Client from './client/client.js'; 20 | 21 | import Cache from './cache/cache.js'; 22 | 23 | import ChatFuncBar from './client/ui/chat_func_bar.js'; 24 | 25 | export { 26 | Contact, 27 | Friend, 28 | Group, 29 | Member, 30 | SingleMessage, 31 | MessageChain, 32 | MessageSource, 33 | PlainText, 34 | Image, 35 | Audio, 36 | At, 37 | AtAll, 38 | Raw, 39 | EventChannel, 40 | Client, 41 | Cache, 42 | ChatFuncBar 43 | } -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/cache/cache.js: -------------------------------------------------------------------------------- 1 | /** 2 | * `Cache` 类是一个工具类,它用于缓存一些对象数据。 3 | * 4 | * 当一个函数返回的数据很少发生改变时,应使用此工具类,将结果缓存,以减少开销。 5 | * 6 | * @property { Map } #caches 缓存数据。 7 | */ 8 | class Cache { 9 | 10 | static #caches = new Map(); 11 | 12 | /** 13 | * 将 `defaultSupplier` 返回的数据以 `key` 为键缓存,并返回数据。 14 | * 15 | * @param { any } key 缓存的键。 16 | * @param { Function } defaultSupplier 返回默认数据的函数。 17 | * @returns { any } 缓存数据。 18 | */ 19 | static withCache(key, defaultSupplier) { 20 | let value = Cache.#caches.get(key); 21 | if (!value) { 22 | value = defaultSupplier(); 23 | Cache.#caches.set(key, value); 24 | } 25 | return value; 26 | } 27 | 28 | /** 29 | * 将 `defaultSupplier` 返回的数据以 `key` 为键缓存,并返回数据。 30 | * 31 | * @param { any } key 缓存的键。 32 | * @param { Function } defaultSupplier 返回默认数据的异步函数。 33 | * @returns { any } 缓存数据。 34 | */ 35 | static async withCacheAsync(key, defaultSupplier) { 36 | let value = Cache.#caches.get(key); 37 | if (!value) { 38 | value = await defaultSupplier(); 39 | Cache.#caches.set(key, value); 40 | } 41 | return value; 42 | } 43 | 44 | } 45 | 46 | export default Cache -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/message_source.js: -------------------------------------------------------------------------------- 1 | /** 2 | * `MessageSource` 类型代表一条消息的来源。 3 | * 4 | * @property { String } #msgId 该消息来源的 **msgId**。 5 | * @property { Contact } #contact 该消息来源的联系人。 6 | */ 7 | class MessageSource { 8 | 9 | #msgId; 10 | 11 | #contact; 12 | 13 | /** 14 | * 通过 **msgId** 和联系人构造一个消息来源。 15 | * 16 | * @param { String } msgId 消息的 **msgId**。 17 | * @param { Contact } contact 来源联系人。 18 | */ 19 | constructor(msgId, contact) { 20 | this.#msgId = msgId; 21 | this.#contact = contact; 22 | } 23 | 24 | /** 25 | * 返回该消息来源的 `#msgId` 属性。 26 | * 27 | * @returns { String } 该消息来源的 `#msgId` 属性。 28 | */ 29 | getMsgId() { 30 | return this.#msgId; 31 | } 32 | 33 | /** 34 | * 返回该消息来源的 `#contact` 属性。 35 | * 36 | * @returns { Contact } 该消息来源的 `#contact` 属性。 37 | */ 38 | getContact() { 39 | return this.#contact; 40 | } 41 | 42 | /** 43 | * 撤回该消息来源所代表的消息。 44 | */ 45 | async recall() { 46 | await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelMsgService/recallMsg', false, { 47 | msgIds: [ 48 | this.#msgId 49 | ], 50 | peer: this.#contact.toPeer() 51 | }); 52 | } 53 | 54 | } 55 | 56 | export default MessageSource -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/plain_text.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from '../../index.js'; 2 | 3 | /** 4 | * `PlainText` 类型代表一个纯文本消息元素。 5 | * 6 | * @property { String } #content 消息内容。 7 | */ 8 | class PlainText extends SingleMessage { 9 | 10 | #content; 11 | 12 | /** 13 | * 返回该消息元素所对应的 **elementType**,值为 **1**。 14 | * 15 | * @returns { Number } 该消息元素所对应的 **elementType**,值为 **1**。 16 | */ 17 | static getElementType() { 18 | return 1; 19 | } 20 | 21 | /** 22 | * 构造一个内容为 `content` 的纯文本消息。 23 | * 24 | * @param { String } content 消息内容。 25 | */ 26 | constructor(content) { 27 | super(); 28 | this.#content = content; 29 | } 30 | 31 | /** 32 | * 返回该消息元素的 `#content` 属性。 33 | * 34 | * @returns { String } 该消息元素的 `#content` 属性。 35 | */ 36 | getContent() { 37 | return this.#content; 38 | } 39 | 40 | /** 41 | * 构造并返回该消息元素所对应的 **element** 对象。 42 | * 43 | * @returns { Native } 该消息元素所对应的 **element** 对象。 44 | */ 45 | async toElement() { 46 | return { 47 | elementId: '', 48 | elementType: PlainText.getElementType(), 49 | textElement: { 50 | content: this.#content 51 | } 52 | }; 53 | } 54 | 55 | } 56 | 57 | export default PlainText -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/at_all.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from '../../index.js'; 2 | 3 | /** 4 | * `AtAll` 类型代表一个 **@全体成员** 消息元素。 5 | * 6 | * @property { String } #content 显示内容。 7 | */ 8 | class AtAll extends SingleMessage { 9 | 10 | #content; 11 | 12 | /** 13 | * 返回该消息元素所对应的 **elementType**,值为 **1**。 14 | * 15 | * @returns { Number } 该消息元素所对应的 **elementType**,值为 **1**。 16 | */ 17 | static getElementType() { 18 | return 1; 19 | } 20 | 21 | /** 22 | * 构造一个显示为 `content` 的 **@全体成员** 消息元素。 23 | * 24 | * @param { String } content 显示内容。 25 | */ 26 | constructor(content = '@全体成员') { 27 | super(); 28 | this.#content = content; 29 | } 30 | 31 | /** 32 | * 返回该消息元素的 `#content` 属性。 33 | * 34 | * @returns { String } 该消息元素的 `#content` 属性。 35 | */ 36 | getContent() { 37 | return this.#content; 38 | } 39 | 40 | /** 41 | * 构造并返回该消息元素所对应的 **element** 对象。 42 | * 43 | * @returns { Native } 该消息元素所对应的 **element** 对象。 44 | */ 45 | async toElement() { 46 | return { 47 | elementId: '', 48 | elementType: AtAll.getElementType(), 49 | textElement: { 50 | atType: 1, 51 | atNtUid: 'all', 52 | content: this.#content 53 | } 54 | }; 55 | } 56 | 57 | } 58 | 59 | export default AtAll -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/client/client.js: -------------------------------------------------------------------------------- 1 | import { Friend, Group } from '../index.js'; 2 | 3 | /** 4 | * `Client` 类型代表自身客户端。 5 | */ 6 | class Client { 7 | 8 | /** 9 | * 获取客户端登录账号的 **qq号**。 10 | * 11 | * @returns { String } 客户端登录账号的 **qq号**。 12 | */ 13 | static getUin() { 14 | return app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Auth?.authData?.uin; 15 | } 16 | 17 | /** 18 | * 获取客户端登录账号的 **uid**。 19 | * 20 | * @returns { String } 客户端登录账号的 **uid**。 21 | */ 22 | static getUid() { 23 | return app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Auth?.authData?.uid; 24 | } 25 | 26 | /** 27 | * 获取客户端好友列表。 28 | * 29 | * @returns { Array } 客户端好友列表。 30 | */ 31 | static getFriends() { 32 | const buddyMap = app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Contact_buddy?.buddyMap; 33 | if (!buddyMap) { 34 | return null; 35 | } 36 | const result = []; 37 | for (const uid in buddyMap) { 38 | result.push(Friend.make(buddyMap[uid].uin, uid)); 39 | } 40 | return result; 41 | } 42 | 43 | /** 44 | * 获取客户端群列表。 45 | * 46 | * @returns { Array } 客户端群列表。 47 | */ 48 | static getGroups() { 49 | const groupList = app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Contact_group?.groupList; 50 | if (!groupList) { 51 | return null; 52 | } 53 | const result = []; 54 | for (const nativeGroup of groupList) { 55 | result.push(Group.make(nativeGroup.groupCode)); 56 | } 57 | return result; 58 | } 59 | 60 | } 61 | 62 | export default Client -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LiteLoaderQQNT-AutoSendMessages 2 | 3 | LiteLoaderQQNT 1.2.0以下用户,请使用1.6.1版本插件! 4 | 5 | ## 目前支持 6 | 本插件支持: 7 | 1. 定时发送 8 | 2. 发送指定消息 9 | 3. 发送到指定群聊(支持多群) 10 | 4. 发送到指定好友(支持多人) 11 | 5. 发送带@信息 12 | 6. 发送图片 13 | 7. 多账号独立配置 14 | 15 | ## 计划支持 16 | - [x] 支持发送带@信息 17 | - [x] 支持私聊 18 | 19 | ## 不会支持 20 | 1. 发送@全体成员信息 - 防止滥用 21 | 2. 发送音频消息 - 我不会写,如果有好心人PR,就可以支持 22 | 23 | ## 说明 24 | 本插件依赖于 25 | 26 | 1. [Euphony](https://github.com/xtaw/LiteLoaderQQNT-Euphony) - 用于提供发送消息接口 27 | 2. [插件检测更新API](https://github.com/adproqwq/LiteLoaderQQNT-CheckUpdateModule) - 用于自动检测更新并下载 28 | 29 | 请在安装本插件前确保已安装以上插件。 30 | 31 | ## 安装方法 32 | 1. 下载最新 [发行版](https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages/releases) 并解压 33 | 2. 将文件夹移动至 `LiteLoaderQQNT数据目录/plugins/` 下面 34 | 3. 重启QQNT即可 35 | 36 | ## 如何为本项目贡献代码 37 | 38 | 请观看[贡献指南](./CONTRIBUTING.md)。 39 | 40 | ## 鸣谢 41 | * [LiteLoaderQQNT](https://github.com/LiteLoaderQQNT/LiteLoaderQQNT/) 42 | * [LiteLoaderQQNT-PluginTemplate-Vite](https://github.com/MisaLiu/LiteLoaderQQNT-PluginTemplate-Vite) 43 | * [LiteLoaderQQNT-Euphony](https://github.com/xtaw/LiteLoaderQQNT-Euphony) 44 | * [LiteLoaderQQNT-lite_tools](https://github.com/xiyuesaves/LiteLoaderQQNT-lite_tools) 45 | 46 | ## License 47 | ``` 48 | LiteLoaderQQNT-AutoSendMessages 49 | Copyright (C) 2024 Adpro 50 | 51 | This program is free software: you can redistribute it and/or modify 52 | it under the terms of the GNU General Public License as published by 53 | the Free Software Foundation, either version 3 of the License, or 54 | (at your option) any later version. 55 | 56 | This program is distributed in the hope that it will be useful, 57 | but WITHOUT ANY WARRANTY; without even the implied warranty of 58 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 59 | GNU General Public License for more details. 60 | 61 | You should have received a copy of the GNU General Public License 62 | along with this program. If not, see . 63 | ``` -------------------------------------------------------------------------------- /src/utils/checkTime.ts: -------------------------------------------------------------------------------- 1 | import dayjs from 'dayjs'; 2 | import toArray from 'dayjs/plugin/toArray'; 3 | import customParseFormat from 'dayjs/plugin/customParseFormat'; 4 | import { readConfig, writeConfig } from './config'; 5 | import timeMode from './timeMode'; 6 | import sendMsgEntry from './sendMsgEntry'; 7 | 8 | export default async () => { 9 | dayjs.extend(toArray); 10 | dayjs.extend(customParseFormat); 11 | let currentConfig = await readConfig(await LLASM.getUid()); 12 | 13 | if (timeMode(currentConfig.sendTime) == 'exactly') { 14 | const formatedActTime = dayjs(currentConfig.sendTime, 'HH:mm').toArray(); 15 | if (formatedActTime[3] == dayjs().get('hour') && formatedActTime[4] == dayjs().get('minute') && !currentConfig.isAct) { 16 | await sendMsgEntry(currentConfig, currentConfig.targets); 17 | } 18 | 19 | const currentTime = `${dayjs().get('hour').toString()}:${dayjs().get('minute').toString()}`; 20 | if (dayjs(currentConfig.lastActTime, 'HH:mm').isBefore(dayjs(currentTime, 'HH:mm'))) { 21 | currentConfig.isAct = false; 22 | writeConfig(await LLASM.getUid(), currentConfig); 23 | } 24 | } 25 | else if (timeMode(currentConfig.sendTime) == 'per') { 26 | if (currentConfig.lastActTime == '') { 27 | await sendMsgEntry(currentConfig, currentConfig.targets); 28 | } 29 | else { 30 | const perMinute = Number(currentConfig.sendTime); 31 | const currentTime = `${dayjs().get('hour').toString()}:${dayjs().get('minute').toString()}`; 32 | 33 | if (dayjs(currentConfig.lastActTime, 'HH:mm').isBefore(dayjs(currentTime, 'HH:mm'))) { 34 | currentConfig.isAct = false; 35 | writeConfig(await LLASM.getUid(), currentConfig); 36 | } 37 | 38 | const diffMinutes = Math.abs((Number(currentTime.split(':')[0]) - Number(currentConfig.lastActTime.split(':')[0])) * 60) + (Math.abs(Number(currentTime.split(':')[1]) - Number(currentConfig.lastActTime.split(':')[1]))); 39 | 40 | if (diffMinutes >= perMinute && !currentConfig.isAct) { 41 | await sendMsgEntry(currentConfig, currentConfig.targets); 42 | } 43 | } 44 | } 45 | }; -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/single_message.js: -------------------------------------------------------------------------------- 1 | import { At, AtAll, PlainText, Image, Audio, Raw } from '../index.js'; 2 | 3 | /** 4 | * `SingleMessage` 类型代表一个消息元素。 5 | */ 6 | class SingleMessage { 7 | 8 | /** 9 | * 从原生消息元素构造出一个 `SingleMessage` 对象。 10 | * 11 | * @param { Native } element 原生消息元素。 12 | * @returns { SingleMessage } 原生消息元素所对应的 `SingleMessage` 对象。 13 | */ 14 | static fromNative(element) { 15 | switch (element?.elementType) { 16 | case PlainText.getElementType(): 17 | case At.getElementType(): 18 | case AtAll.getElementType(): 19 | const textElement = element?.textElement; 20 | switch (textElement?.atType) { 21 | case 0: 22 | return new PlainText(textElement?.content); 23 | case 1: 24 | return new AtAll(textElement?.content); 25 | case 2: 26 | return new At(textElement?.atUid, textElement?.atNtUid); 27 | } 28 | break; 29 | case Image.getElementType(): 30 | return new Image(element?.picElement?.sourcePath); 31 | case Audio.getElementType(): 32 | const pttElement = element?.pttElement; 33 | return new Audio(pttElement?.filePath, pttElement?.duration); 34 | } 35 | return new Raw(element); 36 | } 37 | 38 | /** 39 | * (抽象函数,由子类实现) 40 | * 41 | * 返回该消息元素所对应的 **elementType**。 42 | * 43 | * 特别地, `Raw` 类型并不含有该静态函数。 44 | * 45 | * @returns { Number } 该消息元素所对应的 **elementType**。 46 | */ 47 | static getElementType() { 48 | throw new Error('Abstract method not implemented.'); 49 | } 50 | 51 | /** 52 | * (抽象函数,由子类实现) 53 | * 54 | * 构造并返回该消息元素所对应的 **element** 对象。 55 | * 56 | * @returns { Native } 该消息元素所对应的 **element** 对象。 57 | */ 58 | async toElement() { 59 | throw new Error('Abstract method not implemented.'); 60 | } 61 | 62 | } 63 | 64 | export default SingleMessage -------------------------------------------------------------------------------- /electron.vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'electron-vite'; 2 | import { defineConfig as defineViteConfig } from 'vite'; 3 | import { resolve } from 'path'; 4 | import viteChecker from 'vite-plugin-checker'; 5 | import viteCp from 'vite-plugin-cp'; 6 | import viteZipPack from 'unplugin-zip-pack/vite'; 7 | import PluginManifest from './manifest.json'; 8 | 9 | const SRC_DIR = resolve(__dirname, './src'); 10 | const OUTPUT_DIR = resolve(__dirname, './dist'); 11 | 12 | const BaseConfig = defineViteConfig({ 13 | root: __dirname, 14 | resolve: { 15 | alias: { 16 | '@': SRC_DIR, 17 | }, 18 | }, 19 | }); 20 | 21 | const ConfigBuilder = (type: 'main' | 'preload') => defineViteConfig({ 22 | ...BaseConfig, 23 | 24 | plugins: [ 25 | viteChecker({ 26 | typescript: true, 27 | eslint: { 28 | lintCommand: 'eslint --cache --fix ./src/**/*.{js,cjs,mjs,ts,jsx,tsx}', 29 | }, 30 | }), 31 | ], 32 | build: { 33 | minify: true, 34 | outDir: resolve(OUTPUT_DIR, `./output/${type}`), 35 | lib: { 36 | entry: resolve(SRC_DIR, `./${type}/index.ts`), 37 | formats: [ 'cjs' ], 38 | fileName: () => 'index.js', 39 | }, 40 | }, 41 | }); 42 | 43 | export default defineConfig({ 44 | main: ConfigBuilder('main'), 45 | preload: ConfigBuilder('preload'), 46 | renderer: defineViteConfig({ 47 | ...BaseConfig, 48 | 49 | plugins: [ 50 | viteChecker({ 51 | typescript: true, 52 | eslint: { 53 | lintCommand: 'eslint --cache --fix ./src/**/*.{js,cjs,mjs,ts,jsx,tsx}', 54 | }, 55 | }), 56 | viteCp({ 57 | targets: [ 58 | { src: './manifest.json', dest: 'dist' }, 59 | { src: './changeLog.md', dest: 'dist' }, 60 | { src: './src/pages', dest: 'dist/pages' }, 61 | { src: './src/workers', dest: 'dist/workers' }, 62 | { src: './assets', dest: 'dist/assets' }, 63 | ], 64 | }), 65 | viteZipPack({ 66 | in: OUTPUT_DIR, 67 | out: resolve(__dirname, `./${PluginManifest.slug}.zip`), 68 | }), 69 | ], 70 | build: { 71 | minify: 'esbuild', 72 | outDir: resolve(OUTPUT_DIR, './output/renderer'), 73 | lib: { 74 | entry: resolve(SRC_DIR, './renderer/index.ts'), 75 | formats: [ 'es' ], 76 | fileName: () => 'index.js', 77 | }, 78 | rollupOptions: { 79 | input: resolve(SRC_DIR, './renderer/index.ts'), 80 | }, 81 | }, 82 | }), 83 | }); -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/at.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from '../../index.js'; 2 | 3 | /** 4 | * `At` 类型代表一个 **@群聊成员** 消息元素。 5 | * 6 | * @property { String } #uin 群聊成员的 **qq号**。 7 | * @property { String } #uid 群聊成员的 **uid**。 8 | */ 9 | class At extends SingleMessage { 10 | 11 | #uin; 12 | #uid; 13 | 14 | /** 15 | * 返回该消息元素所对应的 **elementType**,值为 **1**。 16 | * 17 | * @returns { Number } 该消息元素所对应的 **elementType**,值为 **1**。 18 | */ 19 | static getElementType() { 20 | return 1; 21 | } 22 | 23 | /** 24 | * 通过 **qq号** 来构造一个 **@群聊成员** 元素。 25 | * 26 | * 若不存在,则会返回 `null`。 27 | * 28 | * @param { String } uin 群聊成员的 **qq号**。 29 | * @returns { At } 构造出的消息元素。 30 | */ 31 | static fromUin(uin) { 32 | const uid = euphonyNative.convertUinToUid(uin); 33 | if (!uid) { 34 | return null; 35 | } 36 | return new At(uin, uid); 37 | } 38 | 39 | /** 40 | * 通过 **uid** 来构造一个 **@群聊成员** 元素。 41 | * 42 | * 若不存在,则会返回 `null`。 43 | * 44 | * @param { String } uid 群聊成员的 **uid**。 45 | * @returns { At } 构造出的消息元素。 46 | */ 47 | static fromUid(uid) { 48 | const uin = euphonyNative.convertUidToUin(uid); 49 | if (!uin) { 50 | return null; 51 | } 52 | return new At(uin, uid); 53 | } 54 | 55 | /** 56 | * 构造一个 **qq号** 为 `uin`,**uid** 为 `uid` 的 **@群聊成员** 消息元素。 57 | * 58 | * @param { String } uin 群聊成员的 **uin**。 59 | * @param { String } uid 群聊成员的 **uid**。 60 | */ 61 | constructor(uin, uid) { 62 | super(); 63 | this.#uin = uin; 64 | this.#uid = uid; 65 | } 66 | 67 | /** 68 | * 返回该消息元素的 `#uin` 属性。 69 | * 70 | * @returns { String } 该消息元素的 `#uin` 属性。 71 | */ 72 | getUin() { 73 | return this.#uin; 74 | } 75 | 76 | /** 77 | * 返回该消息元素的 `#uid` 属性。 78 | * 79 | * @returns { String } 该消息元素的 `#uid` 属性。 80 | */ 81 | getUid() { 82 | return this.#uid; 83 | } 84 | 85 | /** 86 | * 构造并返回该消息元素所对应的 **element** 对象。 87 | * 88 | * @returns { Native } 该消息元素所对应的 **element** 对象。 89 | */ 90 | async toElement() { 91 | return { 92 | elementId: '', 93 | elementType: At.getElementType(), 94 | textElement: { 95 | atType: 2, 96 | atUid: this.#uin, 97 | atNtUid: this.#uid 98 | } 99 | }; 100 | } 101 | 102 | } 103 | 104 | export default At -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yaml: -------------------------------------------------------------------------------- 1 | name: 提交 Bug 2 | description: 在使用 本插件 过程中遇到了问题 3 | title: "[Bug]: " 4 | labels: ["bug"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | ## 🩵 | 感谢你愿意提交 Bug 报告 11 | ## ❗ | 请确定没有相同问题的 Issue 已被提出。 12 | ## 🌎 | 请准确填写环境信息。 13 | ## ✍️ | 为了避免无效 Issue 占用你我的时间,请按真实情况填写下方表单,谢谢。 14 | --- 15 | - type: checkboxes 16 | id: terms 17 | attributes: 18 | label: 请确保您已阅读以上注意事项,并勾选下方的确认框。 19 | options: 20 | - label: "我已经正确安装了前置插件作为依赖,问题依旧存在。" 21 | required: true 22 | - label: "我已经使用一个仅安装本插件及依赖插件的环境测试过,问题依旧存在。" 23 | required: true 24 | - label: "我已经尝试过删除该插件的配置文件并重启 QQ,问题依旧存在。" 25 | required: true 26 | - label: "我已经在 [Issue Tracker](https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages/issues) 中找过我要提出的问题,没有找到相同问题的 ISSUE。" 27 | required: true 28 | 29 | - type: markdown 30 | attributes: 31 | value: | 32 | ## 环境信息 33 | 34 | - type: input 35 | id: env-qqnt-ver 36 | attributes: 37 | label: QQNT 版本 38 | validations: 39 | required: true 40 | 41 | - type: input 42 | id: env-LiteLoaderQQNT-ver 43 | attributes: 44 | label: LiteLoaderQQNT 版本 45 | validations: 46 | required: true 47 | 48 | - type: input 49 | id: env-Plugin-ver 50 | attributes: 51 | label: 本插件 版本 52 | validations: 53 | required: true 54 | 55 | - type: input 56 | id: env-DepCUMPlugin-ver 57 | attributes: 58 | label: 插件检测更新API插件 版本 59 | validations: 60 | required: true 61 | 62 | - type: input 63 | id: env-DepEPlugin-ver 64 | attributes: 65 | label: Euphony插件 版本 66 | validations: 67 | required: true 68 | 69 | - type: dropdown 70 | id: env-vm-ver 71 | attributes: 72 | label: 运行环境 73 | description: 选择系统版本 74 | options: 75 | - Windows 76 | - MacOS 77 | - Linux 78 | validations: 79 | required: true 80 | 81 | - type: textarea 82 | id: reproduce-steps 83 | attributes: 84 | label: 重现步骤 85 | description: | 86 | 我们需要执行哪些操作才能让 Bug 出现? 87 | validations: 88 | required: true 89 | 90 | - type: textarea 91 | id: expected 92 | attributes: 93 | label: 期望的结果是什么? 94 | validations: 95 | required: true 96 | 97 | - type: textarea 98 | id: actual 99 | attributes: 100 | label: 实际的结果是什么? 101 | validations: 102 | required: true 103 | 104 | - type: textarea 105 | id: extra-desc 106 | attributes: 107 | label: 补充说明(可选) 108 | -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/image.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from '../../index.js'; 2 | 3 | /** 4 | * `Image` 类型代表一个图片消息元素。 5 | * 6 | * @property { String } #path 图片路径。 7 | */ 8 | class Image extends SingleMessage { 9 | 10 | #path; 11 | 12 | /** 13 | * 返回该消息元素所对应的 **elementType**,值为 **2**。 14 | * 15 | * @returns { Number } 该消息元素所对应的 **elementType**,值为 **2**。 16 | */ 17 | static getElementType() { 18 | return 2; 19 | } 20 | 21 | /** 22 | * 构造一个路径为 `path` 的图片消息元素。 23 | * 24 | * @param { String } path 图片路径。 25 | */ 26 | constructor(path) { 27 | super(); 28 | this.#path = path; 29 | } 30 | 31 | /** 32 | * 返回该消息元素的 `#path` 属性。 33 | * 34 | * @returns { String } 该消息元素的 `#path` 属性。 35 | */ 36 | getPath() { 37 | return this.#path; 38 | } 39 | 40 | /** 41 | * 构造并返回该消息元素所对应的 **element** 对象。 42 | * 43 | * @returns { Native } 该消息元素所对应的 **element** 对象。 44 | */ 45 | async toElement() { 46 | const fileMd5 = await euphonyNative.invokeNative('ns-FsApi', 'getFileMd5', false, this.#path); 47 | const imageSize = await euphonyNative.invokeNative('ns-FsApi', 'getImageSizeFromPath', false, this.#path); 48 | const fileSize = await euphonyNative.invokeNative('ns-FsApi', 'getFileSize', false, this.#path); 49 | const cachePath = await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelMsgService/getRichMediaFilePathForGuild', false, { 50 | path_info: { 51 | md5HexStr: fileMd5, 52 | fileName: fileMd5, 53 | elementType: 2, 54 | elementSubType: 0, 55 | thumbSize: 0, 56 | needCreate: true, 57 | downloadType: 1, 58 | file_uuid: '' 59 | } 60 | }); 61 | await euphonyNative.invokeNative('ns-FsApi', 'copyFile', false, { 62 | fromPath: this.#path, 63 | toPath: cachePath 64 | }); 65 | return { 66 | elementId: '', 67 | elementType: Image.getElementType(), 68 | picElement: { 69 | md5HexStr: fileMd5, 70 | fileSize, 71 | picWidth: imageSize.width, 72 | picHeight: imageSize.height, 73 | fileName: fileMd5, 74 | sourcePath: cachePath, 75 | original: true, 76 | picType: 1001, 77 | picSubType: 0, 78 | fileUuid: '', 79 | fileSubId: '', 80 | thumbFileSize: 0, 81 | summary: '', 82 | } 83 | }; 84 | } 85 | 86 | } 87 | 88 | export default Image -------------------------------------------------------------------------------- /src/main/index.ts: -------------------------------------------------------------------------------- 1 | import { app, BrowserWindow, dialog, ipcMain } from 'electron'; 2 | import { normalize } from 'node:path'; 3 | import fs from 'node:fs/promises'; 4 | import { config, ISettingConfig } from '../config/config'; 5 | 6 | let uid: string; 7 | 8 | const readConfig = async (uid: string): Promise => { 9 | const config: ISettingConfig = JSON.parse(await fs.readFile(`${LiteLoader.plugins.auto_send_messages.path.data}/${uid}.json`, 'utf-8')); 10 | 11 | return config; 12 | }; 13 | 14 | const writeConfig = async (uid: string, newConfig: ISettingConfig) => { 15 | await fs.writeFile(`${LiteLoader.plugins.auto_send_messages.path.data}/${uid}.json`, JSON.stringify(newConfig, undefined, 2)); 16 | }; 17 | 18 | ipcMain.on('LLASM.openFileDialog', (_, type: 'chats' | 'groups', uid: string) => { 19 | dialog.showOpenDialog({ 20 | title: '请选择图片', 21 | buttonLabel: '使用该图片', 22 | filters: [ 23 | { 24 | name: 'Images', 25 | extensions: ['jpg', 'png', 'gif'], 26 | }, 27 | ], 28 | properties: ['openFile', 'showHiddenFiles'], 29 | }).then(async (r) => { 30 | if(!r.canceled){ 31 | let userConfig: ISettingConfig = await readConfig(uid); 32 | userConfig.pictures[type] = normalize(r.filePaths[0]); 33 | await writeConfig(uid, userConfig); 34 | } 35 | }); 36 | }); 37 | 38 | ipcMain.on('LLASM.writeConfig', async (_, uid: string, newConfig: ISettingConfig) => { 39 | await writeConfig(uid, newConfig); 40 | }); 41 | 42 | ipcMain.handle('LLASM.getUid', () => { 43 | return uid; 44 | }); 45 | 46 | export const onLogin = async (uid: string) => { 47 | // data 目录检测 48 | try{ 49 | await fs.access(LiteLoader.plugins.auto_send_messages.path.data, fs.constants.F_OK | fs.constants.W_OK | fs.constants.R_OK); 50 | } catch{ 51 | await fs.mkdir(LiteLoader.plugins.auto_send_messages.path.data); 52 | } 53 | 54 | // 数据文件检测 55 | try{ 56 | await fs.access(`${LiteLoader.plugins.auto_send_messages.path.data}/${uid}.json`, fs.constants.F_OK); 57 | } catch{ 58 | await writeConfig(uid, config); 59 | } 60 | 61 | const windows = BrowserWindow.getAllWindows(); 62 | windows[0].webContents.send('LLASM.onLogin' ,uid); 63 | }; 64 | 65 | export const onBrowserWindowCreated = (window: BrowserWindow) => { 66 | window.webContents.send = new Proxy(window.webContents.send, { 67 | apply(target, thisArg, args){ 68 | if(args[0] == 'LLASM.onLogin') uid = args[1]; 69 | 70 | Reflect.apply(target, thisArg, args); 71 | }, 72 | }); 73 | }; 74 | 75 | app.whenReady().then(async () => { 76 | LiteLoader.api.setMinLoaderVer('auto_send_messages', '1.2.0'); 77 | 78 | if(await LiteLoader.api.checkUpdate('auto_send_messages')){ 79 | if(await LiteLoader.api.downloadUpdate('auto_send_messages')) await LiteLoader.api.showRelaunchDialog('auto_send_messages', true); 80 | } 81 | }); -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/contact/contact.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage, MessageSource, Friend, Group, MessageChain } from '../index.js'; 2 | 3 | /** 4 | * `Contact` 类型代表所有的联系人。 5 | * 6 | * @property { String } #id 该联系人的标识,在 `Friend` 中表示好友的 **qq号**,在 `Group` 中表示群聊的 **群号**。 7 | */ 8 | class Contact { 9 | 10 | #id; 11 | 12 | /** 13 | * 返回当前窗口上正在进行的聊天对象。如果没有聊天对象,或聊天对象类型不受支持,则返回 `null`。 14 | * 15 | * @returns { Contact } 当前窗口上正在进行的聊天对象。 16 | */ 17 | static getCurrentContact() { 18 | const contact = app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Aio?.curAioData; 19 | const uin = contact?.header?.uin; 20 | const uid = contact?.header?.uid; 21 | if (!uin || !uid) { 22 | return null; 23 | } 24 | switch (contact.chatType) { 25 | case Friend.getChatType(): 26 | return Friend.make(uin, uid); 27 | case Group.getChatType(): 28 | return Group.make(uin); 29 | } 30 | } 31 | 32 | /** 33 | * (抽象函数,由子类实现) 34 | * 35 | * 返回该联系人类型所对应的 **chatType**。 36 | * 37 | * @returns { Number } 该联系人类型所对应的 **chatType**。 38 | */ 39 | static getChatType() { 40 | throw new Error('Abstract method not implemented.'); 41 | } 42 | 43 | /** 44 | * 仅供子类调用。 45 | * 46 | * @param { String } id 在 `Friend` 中表示好友的 **qq号**,在 `Group` 中表示群聊的 **群号**。 47 | */ 48 | constructor(id) { 49 | this.#id = id; 50 | } 51 | 52 | /** 53 | * 向该联系人发送一条消息,并返回其在服务器上的来源。 54 | * 55 | * @param { MessageChain | SingleMessage } message 消息内容。 56 | * @param { String } msgId 消息的 **msgId**,如果此参数为空则会随机生成。 57 | * @returns { MessageSource } 发送的信息在服务器上的来源。 58 | */ 59 | async sendMessage(message, msgId = undefined) { 60 | if (!msgId) { 61 | msgId = `7${ Array.from({ length: 18 }, () => Math.floor(Math.random() * 10)).join('') }`; 62 | } 63 | await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelMsgService/sendMsg', false, { 64 | msgId, 65 | peer: this.toPeer(), 66 | msgElements: message instanceof SingleMessage ? [ await message.toElement() ] : await message.toElements(), 67 | msgAttributeInfos: new Map() 68 | }); 69 | return new MessageSource(msgId, this); 70 | } 71 | 72 | /** 73 | * 返回该联系人的 `#id` 属性。 74 | * 75 | * @returns { String } 该联系人的 `#id` 属性。 76 | */ 77 | getId() { 78 | return this.#id; 79 | } 80 | 81 | /** 82 | * (抽象函数,由子类实现) 83 | * 84 | * 构造并返回该联系人所对应的 **peer** 对象。 85 | * 86 | * @returns { Native } 该联系人所对应的 **peer** 对象。 87 | */ 88 | toPeer() { 89 | throw new Error('Abstract method not implemented.'); 90 | } 91 | 92 | } 93 | 94 | export default Contact -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/client/ui/chat_func_bar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * `ChatFuncBar` 类型代表客户端聊天窗口输入框上方工具栏。 3 | */ 4 | class ChatFuncBar { 5 | 6 | /** 7 | * 向聊天窗口输入框上方工具栏左侧添加一个按钮。 8 | * 9 | * @param { String } icon 按钮图标。 10 | * @param { Function } onClick 点击事件。 11 | */ 12 | static addLeftButton(icon, onClick) { 13 | const observer = new MutationObserver(mutations => { 14 | mutations.forEach(mutation => { 15 | if (mutation.type === 'childList') { 16 | const nodes = Array.from(mutation.addedNodes); 17 | nodes.forEach(async node => { 18 | if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('chat-func-bar')) { 19 | const chatFuncBarLeft = node.firstElementChild; 20 | chatFuncBarLeft.insertAdjacentHTML('beforeend', await (await fetch(`local:///${ LiteLoader.plugins['euphony'].path.plugin }/src/assets/html/chat_func_bar_button.html`)).text()); 21 | const button = chatFuncBarLeft.lastElementChild; 22 | const buttonIcon = button.firstElementChild; 23 | buttonIcon.innerHTML = icon; 24 | button.addEventListener('click', onClick); 25 | } 26 | }); 27 | } 28 | }); 29 | }); 30 | observer.observe(document.body, { childList: true, subtree: true }); 31 | } 32 | 33 | /** 34 | * 向聊天窗口输入框上方工具栏右侧添加一个按钮。 35 | * 36 | * @param { String } icon 按钮图标。 37 | * @param { Function } onClick 点击事件。 38 | */ 39 | static addRightButton(icon, onClick) { 40 | const observer = new MutationObserver(mutations => { 41 | mutations.forEach(mutation => { 42 | if (mutation.type === 'childList') { 43 | const nodes = Array.from(mutation.addedNodes); 44 | nodes.forEach(async node => { 45 | if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('chat-func-bar')) { 46 | const chatFuncBarRight = node.lastElementChild; 47 | console.log(chatFuncBarRight) 48 | chatFuncBarRight.insertAdjacentHTML('beforeend', await (await fetch(`local:///${ LiteLoader.plugins['euphony'].path.plugin }/src/assets/html/chat_func_bar_button.html`)).text()); 49 | const button = chatFuncBarRight.lastElementChild; 50 | const buttonIcon = button.firstElementChild; 51 | buttonIcon.innerHTML = icon; 52 | button.addEventListener('click', onClick); 53 | } 54 | }); 55 | } 56 | }); 57 | }); 58 | observer.observe(document.body, { childList: true, subtree: true }); 59 | } 60 | 61 | } 62 | 63 | export default ChatFuncBar -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/event/event_channel.js: -------------------------------------------------------------------------------- 1 | import { Friend, Group, MessageChain, MessageSource } from '../index.js'; 2 | 3 | /** 4 | * `EventChannel` 是 **Euphony** 完成事件操作的通道。 5 | * 6 | * @property { Map> } #registry 事件注册表。 7 | */ 8 | class EventChannel { 9 | 10 | #registry = new Map(); 11 | 12 | /** 13 | * 构造并返回一个带有封装事件触发器的事件通道。 14 | * 15 | * @returns { EventChannel } 带有封装事件触发器的事件通道。 16 | */ 17 | static withTriggers() { 18 | const eventChannel = new EventChannel(); 19 | 20 | function onReceiveMessage(payload) { 21 | const msg = payload?.msgList?.[0]; 22 | if (!msg) { 23 | return; 24 | } 25 | const contact = msg.chatType == 1 ? Friend.make(msg.peerUin, msg.peerUid) : (msg.chatType == 2 ? Group.make(msg.peerUin) : null); 26 | const source = new MessageSource(msg.msgId, contact); 27 | eventChannel.call('receive-message', MessageChain.fromNative(msg.elements), source); 28 | } 29 | 30 | euphonyNative.subscribeEvent('nodeIKernelMsgListener/onRecvMsg', onReceiveMessage); 31 | euphonyNative.subscribeEvent('nodeIKernelMsgListener/onRecvActiveMsg', onReceiveMessage); 32 | euphonyNative.subscribeEvent('nodeIKernelMsgListener/onAddSendMsg', payload => { 33 | const msgRecord = payload?.msgRecord; 34 | if (!msgRecord) { 35 | return; 36 | } 37 | const contact = msgRecord.chatType == 1 ? Friend.make(msgRecord.peerUin, msgRecord.peerUid) : (msgRecord.chatType == 2 ? Group.make(msgRecord.peerUin) : null); 38 | const source = new MessageSource(msgRecord.msgId, contact); 39 | eventChannel.call('send-message', MessageChain.fromNative(msgRecord.elements), source); 40 | }); 41 | return eventChannel; 42 | } 43 | 44 | /** 45 | * 为事件 `eventName` 添加一个 `handler` 处理器。 46 | * 47 | * @param { String } eventName 事件名称。 48 | * @param { Function } handler 事件处理器。 49 | * @returns { Function } 传入的 `handler`。 50 | */ 51 | subscribeEvent(eventName, handler) { 52 | if (!this.#registry.has(eventName)) { 53 | this.#registry.set(eventName, []); 54 | } 55 | this.#registry.get(eventName).push(handler); 56 | return handler; 57 | } 58 | 59 | /** 60 | * 移除事件 `eventName` 的 `handler` 处理器。 61 | * 62 | * @param { String } eventName 事件名称。 63 | * @param { Function } handler 事件处理器。 64 | */ 65 | unsubscribeEvent(eventName, handler) { 66 | const event = this.#registry.get(eventName); 67 | if (event) { 68 | const index = event.indexOf(handler); 69 | if (index != -1) { 70 | event.splice(index, 1); 71 | } 72 | } 73 | } 74 | 75 | /** 76 | * 触发事件 `eventName` 并传入参数 `args`。 77 | * 78 | * @param { String } eventName 事件名称。 79 | * @param { ...any } args 事件参数。 80 | */ 81 | call(eventName, ...args) { 82 | this.#registry.get(eventName)?.forEach(handler => handler(...args)); 83 | } 84 | 85 | } 86 | 87 | export default EventChannel -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/message_chain.js: -------------------------------------------------------------------------------- 1 | import { At, AtAll, Audio, Image, PlainText, SingleMessage } from '../index.js'; 2 | 3 | /** 4 | * `MessageChain` 类型代表一条完整的消息,由多个 `SingleMessage` 组成。 5 | * 6 | * @property { Array } #messages 构成该消息链的所有元素。接收的类型应为 `SingleMessage`。 7 | */ 8 | class MessageChain { 9 | 10 | #messages = []; 11 | 12 | /** 13 | * 从原生消息链构造出一个 `MessageChain` 对象。 14 | * 15 | * @param { Native } elements 原生消息链。 16 | * @returns { MessageChain } 原生消息链所对应的 `MessageChain` 对象。 17 | */ 18 | static fromNative(elements) { 19 | const result = new MessageChain(); 20 | for (const element of elements) { 21 | result.append(SingleMessage.fromNative(element)); 22 | } 23 | return result; 24 | } 25 | 26 | /** 27 | * 将一个消息元素添加至该消息链中。 28 | * 29 | * @param { SingleMessage } value 要添加的消息元素。 30 | * @returns { MessageChain } 该消息链。 31 | */ 32 | append(value) { 33 | this.#messages.push(value); 34 | return this; 35 | } 36 | 37 | /** 38 | * 移除该消息链中最后一个消息元素。 39 | * 40 | * @returns { MessageChain } 该消息链。 41 | */ 42 | pop() { 43 | this.#messages.pop(); 44 | return this; 45 | } 46 | 47 | /** 48 | * 移除该消息链中指定位置的消息元素。 49 | * 50 | * @param { Number } index 要移除的消息元素的位置。 51 | * @returns { MessageChain } 该消息链。 52 | */ 53 | remove(index) { 54 | this.#messages.splice(index, 1); 55 | return this; 56 | } 57 | 58 | /** 59 | * 获取该消息链中指定位置的消息元素。 60 | * 61 | * @param { Number } index 要获取的消息元素的位置。 62 | * @returns { SingleMessage } 获取到的消息元素。 63 | */ 64 | get(index) { 65 | return this.#messages[index]; 66 | } 67 | 68 | /** 69 | * 将该消息链转化为与qq原生显示一致的字符串形式。 70 | * 71 | * 例如: 72 | * 73 | * `Image` 将会被视为 "[图片]"。 74 | * 75 | * `Audio` 将会被视为 "[语音]"。 76 | * 77 | * 但由于 `At` 类型不包括群信息,目前 `At` 只会被视为 "**@qq号**" 的形式。 78 | * 79 | * @returns { String } 转化后的字符串。 80 | */ 81 | contentToString() { 82 | const result = []; 83 | for (const message of this.#messages) { 84 | if (message instanceof PlainText) { 85 | result.push(message.getContent()); 86 | } else if (message instanceof At) { 87 | result.push(`@${ message.getUin() }`); 88 | } else if (message instanceof AtAll) { 89 | result.push(message.getContent()); 90 | } else if (message instanceof Image) { 91 | result.push('[图片]'); 92 | } else if (message instanceof Audio) { 93 | result.push('[语音]'); 94 | } 95 | } 96 | return result.join(''); 97 | } 98 | 99 | /** 100 | * 构造并返回该消息链所对应的 **elements** 对象。 101 | * 102 | * @returns { Native } 该消息链所对应的 **elements** 对象。 103 | */ 104 | async toElements() { 105 | return await Promise.all(this.#messages.map(async message => await message.toElement())); 106 | } 107 | 108 | } 109 | 110 | export default MessageChain -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/message/content/audio.js: -------------------------------------------------------------------------------- 1 | import { SingleMessage } from '../../index.js'; 2 | 3 | /** 4 | * `Audio` 类型代表一个语音消息元素。 5 | * 6 | * @property { String } #path 音频路径。 7 | * @property { Number } #duration 语音显示时长(单位:秒)。 8 | */ 9 | class Audio extends SingleMessage { 10 | 11 | #path; 12 | #duration; 13 | 14 | /** 15 | * 返回该消息元素所对应的 **elementType**,值为 **4**。 16 | * 17 | * @returns { Number } 该消息元素所对应的 **elementType**,值为 **4**。 18 | */ 19 | static getElementType() { 20 | return 4; 21 | } 22 | 23 | /** 24 | * 构造一个路径为 `path`,显示时长为 `duration` 的语音消息元素。 25 | * 26 | * 若不传入 `duration`,则 `toElement` 函数会尝试自动计算语音时长(可能完全不准确)。 27 | * 28 | * @param { String } path 音频路径。 29 | * @param { Number } duration 语音显示时长。单位为秒。 30 | */ 31 | constructor(path, duration = undefined) { 32 | super(); 33 | this.#path = path; 34 | this.#duration = duration; 35 | } 36 | 37 | /** 38 | * 返回该消息元素的 `#path` 属性。 39 | * 40 | * @returns { String } 该消息元素的 `#path` 属性。 41 | */ 42 | getPath() { 43 | return this.#path; 44 | } 45 | 46 | /** 47 | * 返回该消息元素的 `#duration` 属性。 48 | * 49 | * @returns { Number } 该消息元素的 `#duration` 属性。 50 | */ 51 | getDuration() { 52 | return this.#duration; 53 | } 54 | 55 | /** 56 | * 构造并返回该消息元素所对应的 **element** 对象。 57 | * 58 | * @returns { Native } 该消息元素所对应的 **element** 对象。 59 | */ 60 | async toElement() { 61 | const fileMd5 = await euphonyNative.invokeNative('ns-FsApi', 'getFileMd5', false, this.#path); 62 | const fileSize = await euphonyNative.invokeNative('ns-FsApi', 'getFileSize', false, this.#path); 63 | const cachePath = await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelMsgService/getRichMediaFilePathForGuild', false, { 64 | path_info: { 65 | md5HexStr: fileMd5, 66 | fileName: fileMd5, 67 | elementType: 2, 68 | elementSubType: 0, 69 | thumbSize: 0, 70 | needCreate: true, 71 | downloadType: 1, 72 | file_uuid: '' 73 | } 74 | }); 75 | await euphonyNative.invokeNative('ns-FsApi', 'copyFile', false, { 76 | fromPath: this.#path, 77 | toPath: cachePath 78 | }); 79 | return { 80 | elementId: '', 81 | elementType: Audio.getElementType(), 82 | pttElement: { 83 | fileName: fileMd5, 84 | filePath: cachePath, 85 | md5HexStr: fileMd5, 86 | fileSize, 87 | duration: this.#duration ?? Math.max(1, Math.round(fileSize / 1024 / 3)), 88 | formatType: 1, 89 | voiceType: 1, 90 | voiceChangeType: 0, 91 | canConvert2Text: true, 92 | waveAmplitudes: [ 93 | 0, 18, 9, 23, 16, 17, 16, 15, 44, 17, 24, 20, 14, 15, 17 94 | ], 95 | fileSubId: '', 96 | playState: 1, 97 | autoConvertText: 0 98 | } 99 | }; 100 | } 101 | 102 | } 103 | 104 | export default Audio -------------------------------------------------------------------------------- /src/global.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare interface ILiteLoaderManifestConfig { 4 | manifest_version: 4; 5 | 6 | type?: 'extension' | 'theme' | 'framework'; 7 | 8 | name: string; 9 | 10 | slug: string; 11 | 12 | description: string; 13 | 14 | version: string; 15 | 16 | icon?: string | null; 17 | 18 | thumb?: string | null; 19 | 20 | authors: ILiteLoaderManifestAuthorsConfig[]; 21 | 22 | dependencies?: string[]; 23 | 24 | platform: [ 25 | 'win32'?, 26 | 'linux'?, 27 | 'darwin'?, 28 | ]; 29 | 30 | injects: { 31 | main?: string; 32 | 33 | preload?: string; 34 | 35 | renderer?: string; 36 | }; 37 | 38 | repository?: { 39 | repo: string; 40 | 41 | branch: string; 42 | 43 | release?: { 44 | tag: string; 45 | 46 | file?: string; 47 | } 48 | }; 49 | }; 50 | 51 | declare interface ILiteLoaderManifestAuthorsConfig { 52 | name: string; 53 | 54 | link: string; 55 | }; 56 | 57 | declare namespace LLASM { 58 | const openFileDialog: (type: 'chats' | 'groups', uid: string) => void; 59 | const onLogin: (callback: (event: Electron.IpcRendererEvent) => void) => void; 60 | const writeConfig: (uid: string, config: ISettingConfig) => void; 61 | const getUid: () => Promise; 62 | } 63 | 64 | declare namespace LiteLoader { 65 | const path: ILiteLoaderPath; 66 | const versions: ILiteLoaderVersion; 67 | const os: ILiteLoaderOS; 68 | const package: ILiteLoaderPackage; 69 | const config: { 70 | LiteLoader: { 71 | disabled_plugins: string[], 72 | } 73 | }; 74 | const plugins: Record; 75 | const api: ILiteLoaderAPI; 76 | 77 | interface ILiteLoaderPath { 78 | root: string, 79 | profile: string, 80 | data: string, 81 | plugins: string, 82 | } 83 | 84 | interface ILiteLoaderVersion { 85 | qqnt: string, 86 | liteloader: string, 87 | node: string, 88 | chrome: string, 89 | electron: string, 90 | } 91 | 92 | interface ILiteLoaderOS { 93 | platform: 'win32' | 'linux' | 'darwin', 94 | } 95 | 96 | interface ILiteLoaderPackage { 97 | liteloader: object, 98 | qqnt: object, 99 | } 100 | 101 | interface ILiteLoaderPlugin { 102 | manifest: ILiteLoaderManifestConfig, 103 | incompatible: boolean, 104 | disabled: boolean, 105 | path: ILiteLoaderPluginPath 106 | } 107 | 108 | interface ILiteLoaderPluginPath { 109 | plugin: string, 110 | data: string, 111 | injects: ILiteLoaderPluginPathInject 112 | } 113 | 114 | interface ILiteLoaderPluginPathInject { 115 | main: string, 116 | renderer: string, 117 | preload: string, 118 | } 119 | 120 | interface ILiteLoaderAPI { 121 | openPath: (path: string) => void, 122 | openExternal: (url: string) => void, 123 | disablePlugin: (slug: string) => void, 124 | registerCompFunc: (type: string, compFunc: (currentVer: string, targetVer: string) => boolean, force?: boolean) => void, 125 | useMirrors: (slug: string, mirrors: ILLCUMMirror[]) => void, 126 | setMinLoaderVer: (slug:string, minLLVersion: string) => void, 127 | checkUpdate: (slug: string, type: string = 'semVer') => Promise, 128 | downloadUpdate: (slug: string, url?: string) => Promise, 129 | showRelaunchDialog: (slug: string, showChangeLog?: boolean, changeLogFile?: string) => Promise, 130 | config: ILiteLoaderAPIConfig, 131 | } 132 | 133 | interface ILiteLoaderAPIConfig { 134 | set: (slug: string, new_config: IConfig) => unknown, 135 | get: (slug: string, default_config?: IConfig) => IConfig, 136 | } 137 | } 138 | 139 | declare interface LLSelectedEvent extends Event { 140 | detail: { 141 | name: string; 142 | value: 'black' | 'white'; 143 | }; 144 | }; 145 | 146 | declare interface HTMLElementEventMap { 147 | selected: LLSelectedEvent; 148 | } -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/contact/friend.js: -------------------------------------------------------------------------------- 1 | import { Cache, Contact } from '../index.js'; 2 | 3 | /** 4 | * `Friend` 类型代表好友。 5 | * 6 | * @property { String } #uid 好友的 **uid**。 7 | */ 8 | class Friend extends Contact { 9 | 10 | #uid; 11 | 12 | /** 13 | * 返回该联系人类型所对应的 **chatType**,值为 **1**。 14 | * 15 | * @returns { Number } 该联系人类型所对应的 **chatType**,值为 **1**。 16 | */ 17 | static getChatType() { 18 | return 1; 19 | } 20 | 21 | /** 22 | * 构造一个 **qq号** 为 `uin`,**uid** 为 `uid` 的好友。 23 | * 24 | * 该函数构造出的好友全局只有一个实例,相同的 `uin` 和 `uid` 将会返回相同的对象。 25 | * 26 | * 在任何情况下,都应该使用该函数来构造好友,而非直接使用构造器。 27 | * 28 | * @param { String } uin 好友的 **qq号**。 29 | * @param { String } uid 好友的 **uid**。 30 | * @returns { Friend } 构造出的好友。 31 | */ 32 | static make(uin, uid) { 33 | return Cache.withCache(`friend-${ uin }-${ uid }`, () => new Friend(uin, uid)); 34 | } 35 | 36 | /** 37 | * 通过 **qq号** 来获取一个好友。 38 | * 39 | * 若不存在,则会返回 `null`。 40 | * 41 | * @param { String } uin 要获取的好友的 **qq号**。 42 | * @returns { Friend } 获取到的好友。 43 | */ 44 | static fromUin(uin) { 45 | const uid = euphonyNative.convertUinToUid(uin); 46 | if (!uid) { 47 | return null; 48 | } 49 | return Friend.make(uin, uid); 50 | } 51 | 52 | /** 53 | * 通过 **uid** 来获取一个好友。 54 | * 55 | * 若不存在,则会返回 `null`。 56 | * 57 | * @param { String } uid 要获取的好友的 **uid**。 58 | * @returns { Friend } 获取到的好友。 59 | */ 60 | static fromUid(uid) { 61 | const uin = euphonyNative.convertUidToUin(uid); 62 | if (!uin) { 63 | return null; 64 | } 65 | return Friend.make(uin, uid); 66 | } 67 | 68 | /** 69 | * 构造一个 **qq号** 为 `uin`,**uid** 为 `uid` 的好友。 70 | * 71 | * 注意:在任何情况下,都不应该直接使用该构造器来构造好友。相反地,你应该使用 `Friend.make(uin, uid)` 函数来构造好友。 72 | * 73 | * @param { String } uin 好友的 **qq号**。 74 | * @param { String } uid 好友的 **uid**。 75 | */ 76 | constructor(uin, uid) { 77 | super(uin); 78 | this.#uid = uid; 79 | } 80 | 81 | /** 82 | * 获取并返回该好友在原生qq中的对象。 83 | * 84 | * @returns { Native } 原生好友对象。 85 | */ 86 | getNative() { 87 | const buddyMap = app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Contact_buddy?.buddyMap; 88 | if (!buddyMap) { 89 | return null; 90 | } 91 | return buddyMap[this.#uid]; 92 | } 93 | 94 | /** 95 | * 返回该好友的 `#uid` 属性。 96 | * 97 | * @returns { String } 该好友的 `#uid` 属性。 98 | */ 99 | getUid() { 100 | return this.#uid; 101 | } 102 | 103 | /** 104 | * 获取并返回该好友的生日。 105 | * 106 | * @returns { Date } 生日。 107 | */ 108 | getBirthday() { 109 | const buddy = this.getNative(); 110 | if (!buddy) { 111 | return null; 112 | } 113 | return new Date(buddy.birthday_year, buddy.birthday_month - 1, buddy.birthday_day); 114 | } 115 | 116 | /** 117 | * 获取并返回该好友的个性签名。 118 | * 119 | * @returns { String } 个性签名。 120 | */ 121 | getBio() { 122 | return this.getNative()?.longNick; 123 | } 124 | 125 | /** 126 | * 获取并返回该好友的昵称。 127 | * 128 | * @returns { String } 昵称。 129 | */ 130 | getNick() { 131 | return this.getNative()?.nick; 132 | } 133 | 134 | /** 135 | * 获取并返回该好友的 **qid**。 136 | * 137 | * @returns { String } **qid**。 138 | */ 139 | getQid() { 140 | return this.getNative()?.qid; 141 | } 142 | 143 | /** 144 | * 获取并返回该好友的好友备注。 145 | * 146 | * @returns { String } 好友备注。 147 | */ 148 | getRemark() { 149 | return this.getNative()?.remark; 150 | } 151 | 152 | /** 153 | * 构造并返回该好友所对应的 **peer** 对象。 154 | * 155 | * @returns { Native } 该好友所对应的 **peer** 对象。 156 | */ 157 | toPeer() { 158 | return { 159 | chatType: Friend.getChatType(), 160 | peerUid: this.#uid, 161 | guildId: '' 162 | }; 163 | } 164 | 165 | } 166 | 167 | export default Friend -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/main/preload.js: -------------------------------------------------------------------------------- 1 | const { contextBridge, ipcRenderer } = require('electron'); 2 | 3 | const convertor = new Map(); 4 | 5 | let { webContentsId } = ipcRenderer.sendSync('___!boot'); 6 | if (!webContentsId) { 7 | webContentsId = 2; 8 | } 9 | 10 | /** 11 | * 调用一个qq底层函数,并返回函数返回值。 12 | * 13 | * @param { String } eventName 函数事件名。 14 | * @param { String } cmdName 函数名。 15 | * @param { Boolean } registered 函数是否为一个注册事件函数。 16 | * @param { ...any } args 函数参数。 17 | * @returns { Promise } 函数返回值。 18 | */ 19 | function invokeNative(eventName, cmdName, registered, ...args) { 20 | return new Promise(resolve => { 21 | const callbackId = crypto.randomUUID(); 22 | const callback = (event, ...args) => { 23 | if (args?.[0]?.callbackId == callbackId) { 24 | ipcRenderer.off(`IPC_DOWN_${ webContentsId }`, callback); 25 | resolve(args[1]); 26 | } 27 | }; 28 | ipcRenderer.on(`IPC_DOWN_${ webContentsId }`, callback); 29 | ipcRenderer.send(`IPC_UP_${ webContentsId }`, { 30 | type: 'request', 31 | callbackId, 32 | eventName: `${ eventName }-${ webContentsId }${ registered ? '-register' : '' }` 33 | }, [ cmdName, ...args ]); 34 | }); 35 | } 36 | 37 | /** 38 | * 为qq底层事件 `cmdName` 添加 `handler` 处理器。 39 | * 40 | * @param { String } cmdName 事件名称。 41 | * @param { Function } handler 事件处理器。 42 | * @returns { Function } 新的处理器。 43 | */ 44 | function subscribeEvent(cmdName, handler) { 45 | const listener = (event, ...args) => { 46 | if (args?.[1]?.[0]?.cmdName == cmdName) { 47 | handler(args[1][0].payload); 48 | } 49 | }; 50 | ipcRenderer.on(`IPC_DOWN_${ webContentsId }`, listener); 51 | return listener; 52 | } 53 | 54 | /** 55 | * 移除qq底层事件的 `handler` 处理器。 56 | * 57 | * 请注意,`handler` 并不是传入 `subscribeEvent` 的处理器,而是其返回的新处理器。 58 | * 59 | * @param { Function } handler 事件处理器。 60 | */ 61 | function unsubscribeEvent(handler) { 62 | ipcRenderer.off(`IPC_DOWN_${ webContentsId }`, handler); 63 | } 64 | 65 | contextBridge.exposeInMainWorld('euphonyNative', { 66 | invokeNative, 67 | subscribeEvent, 68 | unsubscribeEvent, 69 | /** 70 | * 获取 `uin` 代表的 **uid**。 71 | * 72 | * @param { String } uin **qq号**。 73 | * @returns { String } `uin` 代表的 **uid**。 74 | */ 75 | convertUinToUid: uin => convertor.get(uin), 76 | /** 77 | * 获取 `uid` 代表的 **qq号**。 78 | * 79 | * @param { String } uid **uid**。 80 | * @returns { String } `uid` 代表的 **qq号**。 81 | */ 82 | convertUidToUin: uid => convertor.get(uid) 83 | }); 84 | 85 | subscribeEvent('onBuddyListChange', payload => { 86 | for (const category of payload.data) { 87 | for (const buddy of category.buddyList) { 88 | convertor.set(buddy.uin, buddy.uid); 89 | convertor.set(buddy.uid, buddy.uin); 90 | } 91 | } 92 | }); 93 | 94 | subscribeEvent('nodeIKernelGroupListener/onMemberInfoChange', payload => { 95 | for (const [uid, nativeMember] of payload.members) { 96 | convertor.set(nativeMember.uin, uid); 97 | convertor.set(uid, nativeMember.uin); 98 | } 99 | }); 100 | 101 | const memberLoader = subscribeEvent('onGroupListUpdate', payload => { 102 | if (payload.updateType == 1) { 103 | for (const nativeGroup of payload.groupList) { 104 | invokeNative('ns-ntApi', 'nodeIKernelGroupService/createMemberListScene', false, { 105 | groupCode: nativeGroup.groupCode, 106 | scene: 'groupMemberList_MainWindow' 107 | }).then(sceneId => { 108 | invokeNative('ns-ntApi', 'nodeIKernelGroupService/getNextMemberList', false, { 109 | sceneId, 110 | num: nativeGroup.memberCount 111 | }); 112 | }); 113 | } 114 | unsubscribeEvent(memberLoader); 115 | } 116 | }); 117 | 118 | invokeNative('ns-ntApi', 'nodeIKernelGroupListener/onMemberInfoChange', true); 119 | invokeNative('ns-ntApi', 'nodeIKernelBuddyService/getBuddyList', false, { force_update: true }); 120 | invokeNative('ns-ntApi', 'nodeIKernelGroupService/getGroupList', false, { forceFetch: true }); -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/contact/group.js: -------------------------------------------------------------------------------- 1 | import { Cache, Contact, Member } from '../index.js'; 2 | 3 | /** 4 | * `Group` 类型代表群聊。 5 | */ 6 | class Group extends Contact { 7 | 8 | /** 9 | * 返回该联系人类型所对应的 **chatType**,值为 **2**。 10 | * 11 | * @returns { Number } 该联系人类型所对应的 **chatType**,值为 **2**。 12 | */ 13 | static getChatType() { 14 | return 2; 15 | } 16 | 17 | /** 18 | * 构造一个 **群号** 为 `id` 的群聊。 19 | * 20 | * 该函数构造出的群聊全局只有一个实例,相同的 `id` 将会返回相同的对象。 21 | * 22 | * 在任何情况下,都应该使用该函数来构造群聊,而非直接使用构造器。 23 | * 24 | * @param { String } id 群聊的 **群号**。 25 | * @returns { Group } 构造出的群聊。 26 | */ 27 | static make(id) { 28 | return Cache.withCache(`group-${ id }`, () => new Group(id)); 29 | } 30 | 31 | /** 32 | * 构造一个 **群号** 为 `id` 的群聊。 33 | * 34 | * 注意:在任何情况下,都不应该直接使用该构造器来构造群聊。相反地,你应该使用 `Group.make(id)` 函数来构造群聊。 35 | * 36 | * @param { String } id 群聊的 **群号**。 37 | */ 38 | constructor(id) { 39 | super(id); 40 | } 41 | 42 | /** 43 | * 获取并返回该群聊在原生qq中的对象。 44 | * 45 | * @returns { Native } 原生群聊对象。 46 | */ 47 | getNative() { 48 | const groupMap = app?.__vue_app__?.config?.globalProperties?.$store?.state?.common_Contact_group?.groupMap; 49 | if (!groupMap) { 50 | return null; 51 | } 52 | return groupMap[this.getId()]; 53 | } 54 | 55 | /** 56 | * 获取并返回该群聊的群聊名称。 57 | * 58 | * @returns { String } 群聊名称。 59 | */ 60 | getName() { 61 | return this.getNative()?.groupName; 62 | } 63 | 64 | /** 65 | * 获取并返回该群聊的群聊最大人数。 66 | * 67 | * @returns { Number } 群聊最大人数。 68 | */ 69 | getMaxMemberCount() { 70 | return this.getNative()?.maxMember; 71 | } 72 | 73 | /** 74 | * 获取并返回该群聊的群聊人数。 75 | * 76 | * @returns { Number } 群聊人数。 77 | */ 78 | getMemberCount() { 79 | return this.getNative()?.memberCount; 80 | } 81 | 82 | /** 83 | * 获取并返回该群聊的群聊备注。 84 | * 85 | * @returns { String } 群聊备注。 86 | */ 87 | getRemark() { 88 | return this.getNative()?.remarkName; 89 | } 90 | 91 | /** 92 | * 通过 **qq号** 获取该群聊的某个成员。 93 | * 94 | * 若不存在,则会返回 `null`。 95 | * 96 | * @param { String } uin 成员的 **qq号**。 97 | * @returns { Member } 获取到的成员。 98 | */ 99 | getMemberFromUin(uin) { 100 | const uid = euphonyNative.convertUinToUid(uin); 101 | if (!uid) { 102 | return null; 103 | } 104 | return Member.make(this, uin, uid); 105 | } 106 | 107 | /** 108 | * 通过 **uid** 获取该群聊的某个成员。 109 | * 110 | * 若不存在,则会返回 `null`。 111 | * 112 | * @param { String } uid 成员的 **uid**。 113 | * @returns { Member } 获取到的成员。 114 | */ 115 | getMemberFromUid(uid) { 116 | const uin = euphonyNative.convertUidToUin(uid); 117 | if (!uin) { 118 | return null; 119 | } 120 | return Member.make(this, uin, uid); 121 | } 122 | 123 | /** 124 | * 获取该群聊的所有成员。 125 | * 126 | * @returns { Array } 该群聊的所有成员。 127 | */ 128 | async getMembers() { 129 | const sceneId = await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelGroupService/createMemberListScene', false, { 130 | groupCode: this.getId(), 131 | scene: 'groupMemberList_MainWindow' 132 | }); 133 | const members = await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelGroupService/getNextMemberList', false, { 134 | sceneId, 135 | num: this.getMemberCount() 136 | }); 137 | const result = []; 138 | for (const [uid, nativeMember] of members.result.infos) { 139 | result.push(Member.make(this, nativeMember.uin, uid)); 140 | } 141 | return result; 142 | } 143 | 144 | /** 145 | * 构造并返回该群聊所对应的 **peer** 对象。 146 | * 147 | * @returns { Native } 该群聊所对应的 **peer** 对象。 148 | */ 149 | toPeer() { 150 | return { 151 | chatType: Group.getChatType(), 152 | peerUid: this.getId(), 153 | guildId: '' 154 | }; 155 | } 156 | 157 | } 158 | 159 | export default Group -------------------------------------------------------------------------------- /LiteLoaderQQNT-Euphony/src/contact/member.js: -------------------------------------------------------------------------------- 1 | import { Cache, Contact, Group } from '../index.js'; 2 | 3 | /** 4 | * `Member` 类型代表群聊成员。 5 | * 6 | * @property { Group } #group 群聊成员来自的群聊。 7 | * @property { String } #uid 群聊成员的 **uid**。 8 | * @property { String } #cardName 群聊成员的群名片。 9 | * @property { String } #nick 群聊成员的昵称。 10 | * @property { String } #qid 群聊成员的 **qid**。 11 | * @property { String } #remark 群聊成员备注。 12 | */ 13 | class Member extends Contact { 14 | 15 | #group; 16 | #uid; 17 | #cardName; 18 | #nick; 19 | #qid; 20 | #remark; 21 | 22 | static { 23 | euphonyNative.subscribeEvent('nodeIKernelGroupListener/onMemberInfoChange', payload => { 24 | const group = Group.make(payload.groupCode); 25 | for (const [uid, nativeMember] of payload.members) { 26 | const member = Member.make(group, nativeMember.uin, uid); 27 | member.#cardName = nativeMember.cardName; 28 | member.#nick = nativeMember.nick; 29 | member.#qid = nativeMember.qid; 30 | member.#remark = nativeMember.remark; 31 | } 32 | }); 33 | } 34 | 35 | /** 36 | * 返回该联系人类型所对应的 **chatType**,值为 **1**。 37 | * 38 | * @returns { Number } 该联系人类型所对应的 **chatType**,值为 **1**。 39 | */ 40 | static getChatType() { 41 | return 1; 42 | } 43 | 44 | /** 45 | * 构造一个来自 `group` 的 **qq号** 为 `uin`,**uid** 为 `uid` 的群聊成员。 46 | * 47 | * 该函数构造出的群聊成员全局只有一个实例,相同的 `group` `uin` `uid` 将会返回相同的对象。 48 | * 49 | * 在一般情况下,你应该使用 `Group.getMemberFromUin(uin)` 或 `Group.getMemberFromUid(uid)` 函数来获取一个群聊成员,而不是直接构造。 50 | * 51 | * 若有特殊需要,则应该使用该函数来构造群聊成员,而非直接使用构造器。 52 | * 53 | * @param { Group } group 群聊成员来自的群聊。 54 | * @param { String } uin 群聊成员的 **qq号**。 55 | * @param { String } uid 群聊成员的 **uid**。 56 | * @returns { Member } 构造出的群聊成员。 57 | */ 58 | static make(group, uin, uid) { 59 | return Cache.withCache(`member-${ group.getId() }-${ uin }-${ uid }`, () => new Member(group, uin, uid)); 60 | } 61 | 62 | /** 63 | * 构造一个来自 `group` 的 **qq号** 为 `uin`,**uid** 为 `uid` 的群聊成员。 64 | * 65 | * 注意:在任何情况下,都不应该直接使用该构造器来构造群聊成员。相反地,你应该使用 `Member.make(group, uin, uid)` 函数来构造群聊成员。 66 | * 67 | * @param { Group } group 群聊成员来自的群聊。 68 | * @param { String } uin 群聊成员的 **qq号**。 69 | * @param { String } uid 群聊成员的 **uid**。 70 | */ 71 | constructor(group, uin, uid) { 72 | super(uin); 73 | this.#group = group; 74 | this.#uid = uid; 75 | } 76 | 77 | /** 78 | * 返回该群聊成员的 `#group` 属性。 79 | * 80 | * @returns { Group } 该群聊成员的 `#group` 属性。 81 | */ 82 | getGroup() { 83 | return this.#group; 84 | } 85 | 86 | /** 87 | * 返回该群聊成员的 `#uid` 属性。 88 | * 89 | * @returns { String } 该群聊成员的 `#uid` 属性。 90 | */ 91 | getUid() { 92 | return this.#uid; 93 | } 94 | 95 | /** 96 | * 返回该群聊成员的 `#cardName` 属性。 97 | * 98 | * @returns { String } 该群聊成员的 `#cardName` 属性。 99 | */ 100 | getCardName() { 101 | return this.#cardName; 102 | } 103 | 104 | /** 105 | * 返回该群聊成员的 `#nick` 属性。 106 | * 107 | * @returns { String } 该群聊成员的 `#nick` 属性。 108 | */ 109 | getNick() { 110 | return this.#nick; 111 | } 112 | 113 | /** 114 | * 返回该群聊成员的 `#qid` 属性。 115 | * 116 | * @returns { String } 该群聊成员的 `#qid` 属性。 117 | */ 118 | getQid() { 119 | return this.#qid; 120 | } 121 | 122 | /** 123 | * 返回该群聊成员的 `#remark` 属性。 124 | * 125 | * @returns { String } 该群聊成员的 `#remark` 属性。 126 | */ 127 | getRemark() { 128 | return this.#remark; 129 | } 130 | 131 | /** 132 | * 设置该群聊成员的群名片为 `cardName`。 133 | * 134 | * @param { String } cardName 新的群名片。 135 | */ 136 | async setCardName(cardName) { 137 | await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelGroupService/modifyMemberCardName', false, { 138 | cardName, 139 | groupCode: this.#group.getId(), 140 | uid: this.#uid 141 | }); 142 | } 143 | 144 | /** 145 | * 设置该群聊成员的禁言时长为 `duration`。 146 | * 147 | * 若 `duration` 为 0,则会解除该群聊成员的禁言。 148 | * 149 | * 实际上,该函数可以做到只禁言 **1s**,尽管在某些设备上无法显示 **1s** 的时长。 150 | * 151 | * @param { Number } duration 禁言时长(单位:秒)。 152 | */ 153 | async mute(duration) { 154 | await euphonyNative.invokeNative('ns-ntApi', 'nodeIKernelGroupService/setMemberShutUp', false, { 155 | groupCode: this.#group.getId(), 156 | memList: [ 157 | { 158 | timeStamp: duration, 159 | uid: this.#uid 160 | } 161 | ] 162 | }); 163 | } 164 | 165 | /** 166 | * 解除该群聊成员的禁言。效果等价于 `Member.mute(0)`。 167 | */ 168 | async unmute() { 169 | await this.mute(0); 170 | } 171 | 172 | /** 173 | * 构造并返回该群聊成员所对应的 **peer** 对象。 174 | * 175 | * @returns { Native } 该群聊成员所对应的 **peer** 对象。 176 | */ 177 | toPeer() { 178 | return { 179 | chatType: Member.getChatType(), 180 | peerUid: this.#uid, 181 | guildId: '' 182 | }; 183 | } 184 | 185 | } 186 | 187 | export default Member -------------------------------------------------------------------------------- /src/renderer/index.ts: -------------------------------------------------------------------------------- 1 | import checkTime from '../utils/checkTime'; 2 | import { readConfig, writeConfig } from '../utils/config'; 3 | import sendMsgEntry from '../utils/sendMsgEntry'; 4 | import modifyTargets from '../utils/modifyTargets'; 5 | import { config } from '../config/config'; 6 | 7 | LLASM.onLogin(() => { 8 | const pluginPath = LiteLoader.plugins.auto_send_messages.path.plugin; 9 | const intervelWorker = new Worker(`local:///${pluginPath}/workers/interval.js`); 10 | intervelWorker.postMessage(''); 11 | intervelWorker.onmessage = async (e) => { 12 | if(e.data == 'checkTime') await checkTime(); 13 | }; 14 | }); 15 | 16 | export const onSettingWindowCreated = async (view: HTMLElement) => { 17 | const uid = await LLASM.getUid(); 18 | const pluginPath = LiteLoader.plugins.auto_send_messages.path.plugin; 19 | let currentConfig = await readConfig(uid); 20 | 21 | view.innerHTML = await (await fetch(`local:///${pluginPath}/pages/settings.html`)).text(); 22 | (view.querySelector('#groupsMessageContent') as HTMLInputElement).value = currentConfig.messages.groups; 23 | (view.querySelector('#groupsPicturePath') as HTMLInputElement).value = currentConfig.pictures.groups; 24 | (view.querySelector('#groups') as HTMLInputElement).value = currentConfig.groups.join(';'); 25 | (view.querySelector('#chatsMessageContent') as HTMLInputElement).value = currentConfig.messages.chats; 26 | (view.querySelector('#chatsPicturePath') as HTMLInputElement).value = currentConfig.pictures.chats; 27 | (view.querySelector('#chats') as HTMLInputElement).value = currentConfig.chats.join(';'); 28 | (view.querySelector('#time') as HTMLInputElement).value = currentConfig.sendTime; 29 | (view.querySelector('#pluginVersion') as HTMLParagraphElement).innerHTML = LiteLoader.plugins.auto_send_messages.manifest.version; 30 | if(currentConfig.mode == 'black') (view.querySelector('[data-value=black]') as HTMLOptionElement).click(); 31 | else (view.querySelector('[data-value=white]') as HTMLOptionElement).click(); 32 | 33 | (view.querySelector('#actNow') as HTMLButtonElement).addEventListener('click', async () => { 34 | const currentConfig = await readConfig(uid); 35 | 36 | await sendMsgEntry(currentConfig, currentConfig.targets); 37 | }); 38 | 39 | (view.querySelector('#mode') as HTMLSelectElement).addEventListener('selected', async (e) => { 40 | let currentConfig = await readConfig(uid); 41 | currentConfig.mode = e.detail.value; 42 | writeConfig(uid, currentConfig); 43 | await modifyTargets(); 44 | }); 45 | 46 | (view.querySelector('#groupsMessageContent') as HTMLInputElement).addEventListener('change', async (e) => { 47 | let currentConfig = await readConfig(uid); 48 | currentConfig.messages.groups = (e.target as HTMLInputElement).value; 49 | writeConfig(uid, currentConfig); 50 | }); 51 | 52 | (view.querySelector('#openPictureGroups') as HTMLButtonElement).addEventListener('click', async () => { 53 | LLASM.openFileDialog('groups', uid); 54 | }); 55 | 56 | (view.querySelector('#rmPictureGroups') as HTMLButtonElement).addEventListener('click', async () => { 57 | let currentConfig = await readConfig(uid); 58 | currentConfig.pictures.groups = ''; 59 | writeConfig(uid, currentConfig); 60 | }); 61 | 62 | (view.querySelector('#groups') as HTMLInputElement).addEventListener('change', async (e) => { 63 | let currentConfig = await readConfig(uid); 64 | currentConfig.groups = (e.target as HTMLInputElement).value.split(';'); 65 | writeConfig(uid, currentConfig); 66 | await modifyTargets(); 67 | }); 68 | 69 | (view.querySelector('#chats') as HTMLInputElement).addEventListener('change', async (e) => { 70 | let currentConfig = await readConfig(uid); 71 | currentConfig.chats = (e.target as HTMLInputElement).value.split(';'); 72 | writeConfig(uid, currentConfig); 73 | }); 74 | 75 | (view.querySelector('#chatsMessageContent') as HTMLInputElement).addEventListener('change', async (e) => { 76 | let currentConfig = await readConfig(uid); 77 | currentConfig.messages.chats = (e.target as HTMLInputElement).value; 78 | writeConfig(uid, currentConfig); 79 | }); 80 | 81 | (view.querySelector('#openPictureChats') as HTMLButtonElement).addEventListener('click', async () => { 82 | LLASM.openFileDialog('chats', uid); 83 | }); 84 | 85 | (view.querySelector('#rmPictureChats') as HTMLButtonElement).addEventListener('click', async () => { 86 | let currentConfig = await readConfig(uid); 87 | currentConfig.pictures.chats = ''; 88 | writeConfig(uid, currentConfig); 89 | }); 90 | 91 | (view.querySelector('#time') as HTMLInputElement).addEventListener('change', async (e) => { 92 | let currentConfig = await readConfig(uid); 93 | currentConfig.sendTime = (e.target as HTMLInputElement).value; 94 | writeConfig(uid, currentConfig); 95 | }); 96 | 97 | (view.querySelector('#github') as HTMLButtonElement).addEventListener('click', () => { 98 | LiteLoader.api.openExternal('https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages'); 99 | }); 100 | 101 | (view.querySelector('#tutoril') as HTMLButtonElement).addEventListener('click', () => { 102 | LiteLoader.api.openExternal('https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages/blob/main/tutoril.md'); 103 | }); 104 | 105 | (view.querySelector('#fixDataFormat') as HTMLButtonElement).addEventListener('click', async () => { 106 | writeConfig(uid, config); 107 | }); 108 | }; -------------------------------------------------------------------------------- /src/pages/settings.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 定时发送时间 13 | 发送时间。填入 HH:mm 格式时间,在每一天的这个时间触发;填入一个数字,每隔……分钟触发 14 | 15 |
16 |
17 | 18 |
19 | 立即触发 20 | 手动触发一次发送。 21 |
22 |
23 |
24 |
25 |
26 | 27 | 28 | 29 | 30 | 31 |
32 | 模式 33 | 目标选择模式,仅适用于群聊。 34 | 35 | 白名单 36 | 黑名单 37 | 38 |
39 |
40 | 41 |
42 | 消息内容 43 | 要发送的消息内容 44 | 45 |
46 |
47 | 48 |
49 | 发送图片 50 | 要发送的图片 51 | 52 | 选择图片 53 | 移除选择 54 |
55 |
56 | 57 |
58 | 目标群聊 59 | 目标群聊,填入群号。多个群聊之间用英文;间隔。 60 | 61 |
62 |
63 |
64 |
65 |
66 | 67 | 68 | 69 | 70 | 71 |
72 | 消息内容 73 | 要发送的消息内容 74 | 75 |
76 |
77 | 78 |
79 | 发送图片 80 | 要发送的图片 81 | 82 | 选择图片 83 | 移除选择 84 |
85 |
86 | 87 |
88 | 目标QQ 89 | 要发送的好友,填入QQ号。多个QQ号之间用英文;间隔。 90 | 91 |
92 |
93 |
94 |
95 |
96 | 97 | 98 | 99 | 100 | 101 |
102 | 修复数据格式 103 | 执行此操作将会清除所有填写的内容,请谨慎使用! 104 | 修复 105 |
106 |
107 |
108 |
109 |
110 | 111 | 112 | 113 | 114 | 115 |
116 | Github 仓库 117 | https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages 118 | 去看看 119 |
120 |
121 | 122 |
123 | 高级语法教程 124 | https://github.com/adproqwq/LiteLoaderQQNT-AutoSendMessages/blob/main/tutoril.md 125 | 去看看 126 |
127 |
128 | 129 |
130 | 作者 131 | adproqwq(Adpro) 132 |
133 |
134 | 135 |
136 | 版本号 137 | 138 |
139 |
140 |
141 |
142 |
-------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------