Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from rabbitkiller-dev/bridge-next
Browse files Browse the repository at this point in the history
Bridge next
  • Loading branch information
rabbitkiller-dev authored May 5, 2021
2 parents 7e57210 + d7d7486 commit be9bbf6
Show file tree
Hide file tree
Showing 48 changed files with 2,691 additions and 57 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ lerna-debug.log*

go-cqhttp

config.json
src/koishi.config.ts
src/koishi.config.prod.ts
src/el.config.ts
src/el.config.prod.ts
src/el.config.prod.ts
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

## 前置说明
### 关于QQ机器人
想要使用QQ机器人,首先需要安装go-cqhttp。
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp):是一个用来连接QQ并且会将消息通过http或websocket的方式上报给koishi程序。以达到让程序接收消息和发送消息
- [Koishi](https://www.npmjs.com/package/koishi):是一个接入类似go-cqhttp平台的一个机器人nodejs库,用来方便我们使用nodejs制作qq机器人
QQ机器人使用了el-bot的js库
- [mirai-console-loader](https://github.com/iTXTech/mirai-console-loader) 帮助你搭建mirai所需要的环境
- [el-bot](https://docs.bot.elpsy.cn):是一个接入mirai平台的一个机器人nodejs库,用来方便我们使用nodejs制作qq机器人

### 关于Discord机器人
Discord制作机器人不需要类似go-cqhttp的中转程序。官方已经提供了相关api和开发者平台,让开发人员方便的制作机器人

使用[discord.js](https://www.npmjs.com/package/discord.js)库就可以方便的使用
使用[discord.js](https://www.npmjs.com/package/discord.js) 库就可以方便的使用

## 本库安装使用方式
### 一、下载安装go-cqhttp
[详细步骤](https://github.com/Mrs4s/go-cqhttp/blob/master/docs/quick_start.md)
### 一、启动MCL (mirai一键安装环境工具)
> 使用Docker的方式
1. 修改文件 `mcl-1.1.0-beta.1/config/Console/AutoLogin.yml` 添加属于你的qq账号
2. 直接运行命令 `docker-compose up`
正常情况,bot收到消息后,控制台会看的到就成功了

1. 将对应操作系统的go-cqhttp下载到go-cqhttp目录
2. 将go-cqhttp/config.sample.json 复制拷贝成 config.json 并配置
```shell script
"uin": 0, <--- qq号
"password": "", <--- 密码
```
3. 启动go-cqhttp
> 非Docker的方式
1. 安装java jdk 并且11以上的版本,配置好java环境变量, 控制台输入`java --version` 能看到版本信息就正常
2. 修改文件 `mcl-1.1.0-beta.1/config/Console/AutoLogin.yml` 添加属于你的qq账号
3. 进入`mcl-1.1.0-beta.1`目录,运行`./mcl`
正常情况,bot收到消息后,控制台会看的到就成功了

> 注: 推荐使用docker的方式,不只是本地,部署到云环境也方便
### 二、配置
将koishi.sample.ts 复制拷贝成 koishi.config.ts, 并配置下面几项
Expand Down Expand Up @@ -54,7 +58,7 @@ discordBotToken: '',
### 三、运行
```shell script
npm install
npm start
npm run start:dev
```

## 支持功能
Expand All @@ -65,11 +69,15 @@ npm start

### Discord -> QQ
- [x] 回复消息同步至Discord
- [x] 支持图片和gif消息同步至Discord (gif暂不支持)
- [x] 支持图片和gif消息同步至Discord
- [x] 支持回复消息同步至Discord

## 文档相关
官方api文档
- https://discordjs.guide/#before-you-begin
- https://discord.com/developers/applications/781193252094476360/bot
- https://link.zhihu.com/?target=https%3A//amazonaws-china.com/cn/


# ElBot
/autoLogin add <qqNumber> <password>
Empty file added cache/avatar/.gitkeep
Empty file.
Empty file added cache/images/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
mirai-mcl:
ports:
- "8080:8080"
expose:
- "8080"
restart: always
privileged: 'true'
volumes:
- ./mcl-1.1.0-beta.1:/bridge/mcl
- ./cache:/bridge/cache
working_dir: /bridge/mcl
command: ./mcl
image: openjdk:11.0.10-oraclelinux8
volumes:
logvolume01: {}

10 changes: 5 additions & 5 deletions el-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as log from './src/utils/log5';

import {DatabaseService} from "./src/database.service";
import {ElAndDiscordService} from "./src/elAndDiscord.service";
import {BotService} from "./src/el-bot/bot.service";


import bridgeQQToDiscord from './src/bridge-qq-to-discord.el';
Expand All @@ -11,12 +11,12 @@ import bridgeDiscordToQQ from './src/bridge-discord-to-qq.el';
async function main() {
await DatabaseService.init();
log.message('🌈', `数据库连接成功`);
await ElAndDiscordService.initQQBot();
await BotService.initQQBot();
log.message('🌈', `QQ 成功连接`);
await ElAndDiscordService.initDiscord();
log.message('🌈', `Discord 成功登录 ${ElAndDiscordService.discord.user.tag}`);
await BotService.initDiscord();
log.message('🌈', `Discord 成功登录 ${BotService.discord.user.tag}`);
await bridgeQQToDiscord();
await bridgeDiscordToQQ();
}

main().then()
main().then()
Loading

0 comments on commit be9bbf6

Please sign in to comment.