Handle private messages to other people from other clients slightly better

This commit is contained in:
Tulir Asokan
2017-12-10 14:12:05 +02:00
parent 5378749624
commit 781aab1c2c
3 changed files with 11 additions and 7 deletions
+3 -3
View File
@@ -14,11 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
const telegram = require("telegram-mtproto")
const { nextRandomInt } = require("telegram-mtproto/lib/bin")
const fileType = require("file-type")
const pkg = require("../package.json")
const TelegramPeer = require("./telegram-peer")
/**
* @module telegram-puppet
*/
@@ -254,7 +254,7 @@ class TelegramPuppet {
peer: peer.toInputPeer(),
message,
entities,
random_id: ~~(Math.random() * (1 << 30)),
random_id: [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
}
if (!payload.entities) {
// Everything breaks if we send undefined things :/
@@ -271,7 +271,7 @@ class TelegramPuppet {
const result = await this.client("messages.sendMedia", {
peer: peer.toInputPeer(),
media,
random_id: ~~(Math.random() * (1 << 30)),
random_id: [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
})
// TODO use result? (maybe the ID)
return result