diff --git a/bot/bot.js b/bot/bot.js index 0c625b5..16f31f1 100644 --- a/bot/bot.js +++ b/bot/bot.js @@ -67,7 +67,7 @@ class Bot { let startServerConnection = async () => { logger.info("Starting Matrix SDK Client"); await this.client.startClient(); - } + } let connectWithPassword = (err, data) => { if (err === null) { @@ -96,7 +96,7 @@ class Bot { botClient.loginWithToken(this.config.accessToken, connectWithToken); } - updateAvatar(avatarFile, overwrite=false) { + updateAvatar(avatarFile, overwrite = false) { let matrixClient = this.client; let botConfig = this.config; let promises = [Promise.resolve(true)]; @@ -104,7 +104,7 @@ class Bot { promises.push(this.client.getProfileInfo(this.config.userId, "avatar_url") .then((existingAvatarUrl) => { logger.info("Recieved avatar_url: %o", existingAvatarUrl); - if (typeof existingAvatarUrl !== 'undefined' && typeof existingAvatarUrl == 'object' + if (typeof existingAvatarUrl !== 'undefined' && typeof existingAvatarUrl == 'object' && existingAvatarUrl.constructor === Object && Object.keys(existingAvatarUrl).length !== 0 && !overwrite) { logger.info("Avatar already set"); @@ -117,13 +117,13 @@ class Bot { type: "image/jpeg", rawResponse: false }).then((uploadedAvatar) => { - logger.info("Uploaded avatar %o", uploadedAvatar); - matrixClient.setAvatarUrl(uploadedAvatar.content_uri) - .then(() => { - logger.info("Updated %s avatar to %s", botConfig.userId, uploadedAvatar.content_uri); - return true; - }); - }); + logger.info("Uploaded avatar %o", uploadedAvatar); + matrixClient.setAvatarUrl(uploadedAvatar.content_uri) + .then(() => { + logger.info("Updated %s avatar to %s", botConfig.userId, uploadedAvatar.content_uri); + return true; + }); + }); } })); } else { diff --git a/bot/config.js b/bot/config.js index 84acfb0..3808273 100644 --- a/bot/config.js +++ b/bot/config.js @@ -3,7 +3,7 @@ let { logger } = require('./logging'); let loadedConfigs = new Map(); -function sanitizeConfig(config, fields=[]) { +function sanitizeConfig(config, fields = []) { let clonedConfig = { ...config }; fields.forEach((field) => { clonedConfig[field] = '******' @@ -11,7 +11,7 @@ function sanitizeConfig(config, fields=[]) { return clonedConfig; } -function getConfig(configFile, sanitizedFields=[], reload=false) { +function getConfig(configFile, sanitizedFields = [], reload = false) { if (loadedConfigs.has(configFile) && !reload) { return loadedConfigs.get(configFile); } else { diff --git a/bot/engine.js b/bot/engine.js index db8766b..acd031e 100644 --- a/bot/engine.js +++ b/bot/engine.js @@ -7,7 +7,7 @@ let message = require('./message'); let utility = require('./utility'); let { initModule } = require('./module/abstract'); -let sentinelValue = '!'; +let commandPrefix = '!'; class Engine { constructor(config, bot, modules) { @@ -65,7 +65,7 @@ class Engine { } else { let messageBody = event.event.content.body; logger.debug("[%s] %s", room.name, messageBody); - if (messageBody.indexOf(sentinelValue) === 0) { + if (messageBody.indexOf(commandPrefix) === 0) { let command = messageBody.split(' ')[0].substring(1); if (engine.commandMap.has(command)) { engine.commandMap.get(command).handleMessage(event, room, sendResponseMessageCallback(engine.bot)); diff --git a/bot/message.js b/bot/message.js index 9c936bf..7a13662 100644 --- a/bot/message.js +++ b/bot/message.js @@ -3,7 +3,7 @@ let messageTypes = { NOTICE: 'm.notice' } -function createBasicMessage(body, msgtype=messageTypes.TEXT) { +function createBasicMessage(body, msgtype = messageTypes.TEXT) { return { "body": body, "msgtype": msgtype diff --git a/bot/module/giphy.js b/bot/module/giphy.js index 2015b4e..fe84d14 100644 --- a/bot/module/giphy.js +++ b/bot/module/giphy.js @@ -36,10 +36,10 @@ class GiphyModule extends AbstractModule { */ cmd_search(...args) { return this.getGiphySearch(args[0]) - .then((response) => { - // logger.debug("Giphy response: %o", response.data.data[0].url); - return response.data.data[0].embed_url; - }) + .then((response) => { + // logger.debug("Giphy response: %o", response.data.data[0].url); + return response.data.data[0].embed_url; + }) } } diff --git a/bot/module/index.js b/bot/module/index.js index cd1220f..898020c 100644 --- a/bot/module/index.js +++ b/bot/module/index.js @@ -2,8 +2,8 @@ * Manage the registered modules */ - let admin = require('./admin'); - let giphy = require('./giphy') +let admin = require('./admin'); +let giphy = require('./giphy') function getModules() { return [