Commit d136d7ca authored by nanahira's avatar nanahira

fixes

parent d3184f33
...@@ -19,8 +19,6 @@ This project may possibly be working only with Hisoutensoku ver 1.10a. Versions ...@@ -19,8 +19,6 @@ This project may possibly be working only with Hisoutensoku ver 1.10a. Versions
* Create a `config.yaml` with the following below. * Create a `config.yaml` with the following below.
```yaml ```yaml
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. coolq: # CoolQ config. The docker-compose config below meets this configuration.
host: coolq host: coolq
accessToken: aaaaa accessToken: aaaaa
......
import bunyan from "bunyan"; import bunyan from "bunyan";
import fs from "fs"; import fs from "fs";
import { CQWebSocket } from "cq-websocket"; import { CQWebSocket, CQEvent, CQTag } from "cq-websocket";
import _ from "underscore"; import _ from "underscore";
import yaml from "yaml"; import yaml from "yaml";
import { spawn } from "child_process"; import { spawn } from "child_process";
...@@ -20,7 +20,7 @@ interface Config { ...@@ -20,7 +20,7 @@ interface Config {
coolq: CoolQConfig; coolq: CoolQConfig;
floodQQGroups: Array<number>; floodQQGroups: Array<number>;
attackTimeout: number; attackTimeout: number;
addressWhitelist: string[] addressWhitelist: string[];
} }
const log = bunyan.createLogger({ const log = bunyan.createLogger({
...@@ -60,7 +60,7 @@ async function startAttack(address: string, port: number): Promise<boolean> { ...@@ -60,7 +60,7 @@ async function startAttack(address: string, port: number): Promise<boolean> {
return true; return true;
} }
async function messageHandler(data: any): Promise<void> { async function messageHandler(event: CQEvent, data: any, tags: CQTag[]): Promise<void> {
const groupID: number = data.group_id; const groupID: number = data.group_id;
if (!groupID || !_.contains(config.floodQQGroups, groupID)) { if (!groupID || !_.contains(config.floodQQGroups, groupID)) {
return; return;
...@@ -83,7 +83,17 @@ async function main(): Promise<void> { ...@@ -83,7 +83,17 @@ async function main(): Promise<void> {
CoolQ = new CQWebSocket(config.coolq); CoolQ = new CQWebSocket(config.coolq);
CoolQ.on("ready", async () => { CoolQ.on("ready", async () => {
log.info("bot init finished."); log.info("bot init finished.");
}) });
CoolQ.on("error", async (err) => {
log.warn("bot error", err.toString());
});
CoolQ.on("socket.error", async (err) => {
log.warn("bot socket error", err.toString());
});
CoolQ.on("socket.close", async (err) => {
log.warn("bot socket close", err.toString());
});
CoolQ.on("message", messageHandler); CoolQ.on("message", messageHandler);
CoolQ.connect();
} }
main(); 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