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