Skip to content

Commit

Permalink
refactor: remove botanio
Browse files Browse the repository at this point in the history
Removed due to uselessnes
  • Loading branch information
atassis committed May 18, 2018
1 parent 7bddd8b commit 0686731
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require('dotenv').config()
const debug = require('debug')('rubot:index')

const config = require('./config')
Expand Down Expand Up @@ -40,7 +39,6 @@ catch (error) {

const bot = createBot(
config.bot.token,
config.bot.botanioToken,
features,
{ username: config.bot.username }
)
Expand Down
18 changes: 1 addition & 17 deletions src/lib/runtime.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const debug = require('debug')('rubot:lib:runtime')
const Telegraf = require('telegraf')
const Botanio = require('botanio')

const extendedContext = require('./extended-context')
const { push } = require('./elastic')
Expand All @@ -25,29 +24,14 @@ function installFeatures(bot, featureList) {
* @param {{ username: string }} telegrafConfig
* @return {Telegraf}
*/
function createBot(token, botanioToken, features, telegrafConfig = {}) {
function createBot(token, features, telegrafConfig = {}) {
debug('createBot()', telegrafConfig)
const instance = new Telegraf(token, telegrafConfig)
const botan = Botanio(botanioToken)

instance.use((ctx, next) => {
ctx.botan = botan
next()
})

if (process.env.NODE_ENV === 'development') {
instance.use(Telegraf.log())
}

if (process.env.BOTANIO_LOG) {
instance.use((ctx, next) => {
if (ctx.update.message) {
ctx.botan.track(ctx.update.message, 'update')
}
next()
})
}

if (process.env.ELASTIC_LOG) {
instance.use((ctx, next) => {
if (ctx.update.message) {
Expand Down

0 comments on commit 0686731

Please sign in to comment.