Commit 35094731 authored by nanahira's avatar nanahira

add stub bot

parent 564408f1
Pipeline #2443 passed with stages
in 2 minutes and 53 seconds
import { Bot, BotOptions, ChatMessage, createBot } from "mineflayer";
import Bunyan, { LogLevel } from "bunyan";
import { delay } from "q";
export type MessageQueueMap = Map<string, (message: string) => void>;
......@@ -33,12 +34,25 @@ export class Minecraft {
}
}
}
constructor(options: BotOptions, debugLevel?: LogLevel) {
this.log = Bunyan.createLogger({ name: options.username, level: debugLevel });
this.options = options;
this.bot = createBot(options);
this.messageWaitQueue = new Map();
this.messageRejectQueue = new Map();
private async stubBot() {
const bot = createBot(this.options);
await new Promise<void>((resolve) => {
bot.once("spawn", () => {
this.log.info("stub sapwn");
bot.end();
});
bot.once("end", () => {
this.log.info("stub end");
resolve();
});
});
}
private async launchBot() {
//for (let i = 0; i < 3; ++i) {
await this.stubBot();
await delay(3000);
//}
this.bot = createBot(this.options);
this.bot.once("spawn", () => {
this.log.info("connected");
if (this.spawnCallback) {
......@@ -66,7 +80,14 @@ export class Minecraft {
this.resolveQueue(line);
}
});
}
constructor(options: BotOptions, debugLevel?: LogLevel) {
this.log = Bunyan.createLogger({ name: options.username, level: debugLevel });
this.options = options;
this.messageWaitQueue = new Map();
this.messageRejectQueue = new Map();
this.died = false;
this.launchBot();
}
waitForConnect() {
return new Promise<void>((resolve, reject) => {
......
#!/bin/bash
# curl https://water.mycard.moe:9000/nanahira/wolfx/china.sh | sudo bash -
# curl https://cdn01.moecube.com/wolfx/china.sh | sudo bash -
apt-get update
apt-get -y install docker.io python3-pip
/usr/bin/pip3 install -U pip
/usr/local/bin/pip install -U docker-compose
echo 'nameserver 114.114.114.114' > /etc/resolv.conf
wget -O docker-compose.yml https://water.mycard.moe:9000/nanahira/wolfx/docker-compose-china.yml
wget -O docker-compose.yml https://cdn01.moecube.com/wolfx/docker-compose-china.yml
docker-compose up
......@@ -4,4 +4,4 @@ services:
image: ccr.ccs.tencentyun.com/nanahira/wolfx:latest
scale: 5
environment:
USERNAME: Ayane
USERNAME: Momobako
......@@ -4,4 +4,4 @@ services:
image: nanahira/wolfx-money
scale: 5
environment:
USERNAME: Ayane
USERNAME: Momobako
#!/bin/bash
# curl https://water.mycard.moe:9000/nanahira/wolfx/run.sh | sudo bash -
# curl https://cdn01.moecube.com/wolfx/run.sh | sudo bash -
apt-get update
apt-get -y install docker.io python3-pip
/usr/bin/pip3 install -U pip
/usr/local/bin/pip install -U docker-compose
wget -O docker-compose.yml https://water.mycard.moe:9000/nanahira/wolfx/docker-compose.yml
apt-get -y install docker.io docker-compose
wget -O docker-compose.yml https://cdn01.moecube.com/wolfx/docker-compose.yml
docker-compose up
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