Skip to content
Habib Rohman edited this page Jul 8, 2020 · 4 revisions

There are three ways to use minetelegram

  1. Local Setup - Run minetelegram localy on your PC.
  2. Heroku Setup - Run minetelegram on heroku server.
  3. As Mineflayer Plugin - Add minetelegram as your mineflayer plugin.

Local Setup

Installation / update:

npm install -g minetelegram@latest

Example :

minetelegram --token BOT_TOKEN --id TELEGRAM_USER_ID --username myusername --server play.myserver.mine --mcversion 1.13.2

If you stuck? do minetelegram --help

usage: minetelegram [-h] [-v] -t TOKEN -i ID [-c {on,off}] [-w {on,off}]
                [-m {on,off}] [-f FILTERS] [-e {on,off}]


Minecraft - Telegram bridge

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -t TOKEN, --token TOKEN
                        telegram bot token, created from @botfather
  -i ID, --id ID        your telegram user id, get your id from @myidbot
  -c {on,off}, --chat {on,off}
                        Send every chat to telegram, default : on
  -w {on,off}, --whisper {on,off}
                        Send every whisper to telegram, default : on
  -m {on,off}, --message {on,off}
                        Send every message packet to telegram. Turning this
                        on will overide --chat & --whisper to off, default :
                        off
  -f FILTERS, --filters FILTERS
                        Value dilimited by ;, eg. "welcome;bye" this will
                        prevent send to telegram chat message containing
                        welcome or bye
  -e {on,off}, --echo {on,off}
                        echo everything to console?, default : on

Heroku Setup

Here's step by step process to deploy minetelegram to heroku.

Deployment

  1. Register / Login to heroku.

  2. Then press the Deploy to heroku button.

  3. Set app name & choose a region if you want.

  4. Then set config vars as folowing A var with key TOKEN set the value to your telegram bot token, Get here. A var with key USER set the value to your telegram user id, Get here. More on How to set heroku config vars

  5. Finally wait until app deployed.

To install latest minetelegram update just repeat the same deployment process.


As Mineflayer Plugin

Installation :

npm install minetelegram --save

Example :

const { createMinetelegram } = require('minetelegram')

const minetelegramOptions = {
  token: TOKEN,
  user: USER,
  echo: true,
  filters: [], // default filters for bot
  commands: {}, // default commands? not recomended
  plugins: [], // list of mineflayer your plugins
  chat: true, // send minecraft chat to telegram
  whisper: true, // send minecraft whisper to telegram
  message: false // send all minecraft message to telegram, enabling this will overide chat & whisper to false
}

const minetelegram = createMinetelegram(minetelegramOptions)

// add your default commands here !!!
// minetelegram.addCommand('hi', function, 'test')

// add plugin to use in each instance of bot
function somePlugin (bot) {
  function someFunction() {
    bot.chat('Yay!');
  }
  bot.someFunction = someFunction;
minetelegram.addPlugin(somePlugin)

// to create a bot instance
const bot = minetelegram.createBot({
  host: 'localhost', // optional
  port: 25565, // optional
  username: '[email protected]', // email and password are required only for
  password: '12345678', // online-mode=true servers
  version: false // false corresponds to auto version detection (that's the default), put for example "1.8.8" if you need a specific version
})

// add your code for specific bot here before minetelegram.launch()

minetelegram.launch()