-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Slord6/typescriptify
Typescriptify
- Loading branch information
Showing
15 changed files
with
1,148 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Bot } from "mineflayer"; | ||
|
||
interface Message { | ||
bot: Bot; | ||
message: string; | ||
} | ||
|
||
export class ChatBuffer { | ||
private chatStack: Message[] = []; | ||
private messageWaitTime: number; | ||
|
||
constructor(messageWaitTime: number = 2000) { | ||
this.messageWaitTime = messageWaitTime; | ||
} | ||
|
||
public start() { | ||
if (this.chatStack.length > 0) { | ||
let info = this.chatStack.shift() as Message; | ||
console.log(`${info.bot.player.username} sending>>>`, info.message); | ||
info.bot.chat(info.message); | ||
} | ||
setTimeout(this.start.bind(this), this.messageWaitTime); | ||
} | ||
|
||
public addChat(bot: Bot, message: string, directTo: string | null = null) { | ||
message.split('\n').forEach(message => { | ||
if (!directTo) { | ||
this.chatStack.push({ bot, message }); | ||
} else { | ||
this.chatStack.push({ bot, message: `/msg ${directTo} ` + message }); | ||
} | ||
}); | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.