Commit d3184f33 authored by nanahira's avatar nanahira

use coolq websocket

parent 84530471
......@@ -22,9 +22,9 @@ This project may possibly be working only with Hisoutensoku ver 1.10a. Versions
address: 0.0.0.0 # CoolQ listen address and port. Leave it.
port: 80
coolq: # CoolQ config. The docker-compose config below meets this configuration.
apiRoot: http://coolq:5700
host: coolq
accessToken: aaaaa
secret: bbbbb
qq: 1111111111 # Your QQ account here
attackTimeout: 10000 # The timeout the fake clients would wait for connection.
floodQQGroups: # Target QQ groups
- 111111111
......@@ -48,10 +48,9 @@ services:
VNC_PASSWD: YOUR_VNC_PASSWORD_HERE # Please change this
COOLQ_ACCOUNT: 1111111111 # Your QQ account here
FORCE_ENV: 'true'
CQHTTP_POST_URL: http://terminator
CQHTTP_SERVE_DATA_FILES: 'yes'
CQHTTP_USE_WS: 'true'
CQHTTP_SERVE_DATA_FILES: 'true'
CQHTTP_ACCESS_TOKEN: aaaaa # The above access token and secrets. Since the containers are not exposed to the public, you may not use strong ones.
CQHTTP_SECRET: bbbbb
terminator:
restart: always
image: nanahira/hisoutensoku-terminator
......
This diff is collapsed.
import bunyan from "bunyan";
import fs from "fs";
import CQHttp from "cqhttp";
import { CQWebSocket } from "cq-websocket";
import _ from "underscore";
import yaml from "yaml";
import { spawn } from "child_process";
......@@ -8,9 +8,10 @@ import { Attacker } from "./attacker";
import moment from "moment";
interface CoolQConfig {
apiRoot: string;
host: string;
port: number;
qq: number;
accessToken: string;
secret: string;
}
interface Config {
......@@ -26,7 +27,7 @@ const log = bunyan.createLogger({
name: "hisoutensoku-terminator"
});
let CoolQ: CQHttp, config: Config;
let CoolQ: CQWebSocket, config: Config;
function sleep(time: number): Promise<void> {
return new Promise((resolve, reject) => {
......@@ -79,8 +80,10 @@ async function messageHandler(data: any): Promise<void> {
async function main(): Promise<void> {
config = yaml.parse(await fs.promises.readFile("./config.yaml", "utf8")) as Config;
CoolQ = new CQHttp(config.coolq);
CoolQ = new CQWebSocket(config.coolq);
CoolQ.on("ready", async () => {
log.info("bot init finished.");
})
CoolQ.on("message", messageHandler);
CoolQ.listen(config.port, config.address);
}
main();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment