Handle private messages to other people from other clients slightly better
This commit is contained in:
+2
-2
@@ -13,7 +13,7 @@
|
||||
"colors": "1.1.x",
|
||||
"commander": "2.12.x",
|
||||
"escape-html": "1.0.x",
|
||||
"file-type": "^7.3.0",
|
||||
"file-type": "7.4.x",
|
||||
"marked": "0.3.x",
|
||||
"matrix-appservice-bridge": "1.x.x",
|
||||
"matrix-js-sdk": "0.x.x",
|
||||
@@ -24,7 +24,7 @@
|
||||
"yamljs": "0.3.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.x",
|
||||
"eslint": "4.13.x",
|
||||
"eslint-config-airbnb-base": "12.1.x",
|
||||
"eslint-plugin-import": "2.8.x",
|
||||
"jsdoc": "3.5.x"
|
||||
|
||||
@@ -42,10 +42,14 @@ class TelegramPeer {
|
||||
case "peerChat":
|
||||
return new TelegramPeer("chat", peer.chat_id)
|
||||
case "peerUser":
|
||||
return new TelegramPeer("user", sender, {
|
||||
const args = {
|
||||
accessHash: peer.access_hash,
|
||||
receiverID,
|
||||
})
|
||||
}
|
||||
if (sender === receiverID && peer.user_id !== receiverID) {
|
||||
return new TelegramPeer("user", peer.user_id, args)
|
||||
}
|
||||
return new TelegramPeer("user", sender, args)
|
||||
case "peerChannel":
|
||||
return new TelegramPeer("channel", peer.channel_id, {
|
||||
accessHash: peer.access_hash,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user