Implement room and user creation

This commit is contained in:
Tulir Asokan
2017-11-16 11:54:01 +02:00
parent eb2de79a4b
commit 9d705bd5c8
6 changed files with 137 additions and 47 deletions
+31
View File
@@ -18,6 +18,21 @@ const os = require("os")
const telegram = require("telegram-mtproto")
const TelegramPeer = require("./telegram-peer")
const META_FROM_FILETYPE = {
"storage.fileGif": {
mimetype: "image/gif",
extension: "gif",
},
"storage.fileJpeg": {
mimetype: "image/jpeg",
extension: "jpeg",
},
"storage.filePng": {
mimetype: "image/png",
extension: "png",
},
}
/**
* TelegramPuppet represents a Telegram account being controlled from Matrix.
*/
@@ -306,6 +321,22 @@ class TelegramPuppet {
}
}, 5000)
}
async getFile(location) {
location = Object.assign({}, location, {_: "inputFileLocation"})
delete location.dc_id
const file = await this.client("upload.getFile", {
location,
offset: 0,
limit: 100*1024*1024,
})
const meta = META_FROM_FILETYPE[file.type._]
if (meta) {
file.mimetype = meta.mimetype
file.extension = meta.extension
}
return file
}
}
module.exports = TelegramPuppet