Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createBot } from 'mineflayer'
- import { MessageHandler } from './MessageHandler'
- import log from 'npmlog'
- import { ping } from 'minecraft-protocol'
- export class Bot {
- client: any
- handler: MessageHandler
- password: string
- username: string
- constructor(username: string, password: string) {
- var Socks = require("socks5-client");
- var proxy = { host: '212.237.54.194', port: 8118 };
- this.password = password
- this.username = username
- log.info('', 'Logging in', username, 'with password', password)
- ping({ host: 'zielski.ench.pl', version: '1.8' }, (err, result) => {
- if (err) return console.error(err)
- console.dir(result, { colors: true })
- this.client = createBot({
- stream: Socks.createConnection({
- socksHost: proxy.host,
- socksPort: proxy.port
- }),
- username, host: 'zielski.ench.pl', version: '1.8'
- })
- this.handler = new MessageHandler(this)
- this.client.on('kicked', reason => log.info('', 'Kicked for:', reason))
- this.client.on('message', this.handler.onIncoming)
- this.client.on('end', () => console.log('Rozlaczono.') || process.exit(0))
- })
- }
- chat(message: string) {
- this.client.chat(message)
- }
- chatDelay(message: string, timeout: number) {
- setTimeout(() => this.chat(message), timeout)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement