|
|
@ -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 { |
|
|
|