Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createBot } from 'mineflayer'
  2. import { MessageHandler } from './MessageHandler'
  3. import log from 'npmlog'
  4. import { ping } from 'minecraft-protocol'
  5.  
  6. export class Bot {
  7.   client: any
  8.   handler: MessageHandler
  9.   password: string
  10.   username: string
  11.  
  12.   constructor(username: string, password: string) {
  13.     var Socks = require("socks5-client");
  14.     var proxy = { host: '212.237.54.194', port: 8118 };
  15.     this.password = password
  16.     this.username = username
  17.     log.info('', 'Logging in', username, 'with password', password)
  18.     ping({ host: 'zielski.ench.pl', version: '1.8' }, (err, result) => {
  19.       if (err) return console.error(err)
  20.       console.dir(result, { colors: true })
  21.       this.client = createBot({
  22.  
  23.         stream: Socks.createConnection({
  24.           socksHost: proxy.host,
  25.           socksPort: proxy.port
  26.         }),
  27.         username, host: 'zielski.ench.pl', version: '1.8'
  28.       })
  29.       this.handler = new MessageHandler(this)
  30.       this.client.on('kicked', reason => log.info('', 'Kicked for:', reason))
  31.       this.client.on('message', this.handler.onIncoming)
  32.       this.client.on('end', () => console.log('Rozlaczono.') || process.exit(0))
  33.     })
  34.   }
  35.  
  36.   chat(message: string) {
  37.     this.client.chat(message)
  38.   }
  39.  
  40.   chatDelay(message: string, timeout: number) {
  41.     setTimeout(() => this.chat(message), timeout)
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement