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",
|
"colors": "1.1.x",
|
||||||
"commander": "2.12.x",
|
"commander": "2.12.x",
|
||||||
"escape-html": "1.0.x",
|
"escape-html": "1.0.x",
|
||||||
"file-type": "^7.3.0",
|
"file-type": "7.4.x",
|
||||||
"marked": "0.3.x",
|
"marked": "0.3.x",
|
||||||
"matrix-appservice-bridge": "1.x.x",
|
"matrix-appservice-bridge": "1.x.x",
|
||||||
"matrix-js-sdk": "0.x.x",
|
"matrix-js-sdk": "0.x.x",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"yamljs": "0.3.x"
|
"yamljs": "0.3.x"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "4.12.x",
|
"eslint": "4.13.x",
|
||||||
"eslint-config-airbnb-base": "12.1.x",
|
"eslint-config-airbnb-base": "12.1.x",
|
||||||
"eslint-plugin-import": "2.8.x",
|
"eslint-plugin-import": "2.8.x",
|
||||||
"jsdoc": "3.5.x"
|
"jsdoc": "3.5.x"
|
||||||
|
|||||||
@@ -42,10 +42,14 @@ class TelegramPeer {
|
|||||||
case "peerChat":
|
case "peerChat":
|
||||||
return new TelegramPeer("chat", peer.chat_id)
|
return new TelegramPeer("chat", peer.chat_id)
|
||||||
case "peerUser":
|
case "peerUser":
|
||||||
return new TelegramPeer("user", sender, {
|
const args = {
|
||||||
accessHash: peer.access_hash,
|
accessHash: peer.access_hash,
|
||||||
receiverID,
|
receiverID,
|
||||||
})
|
}
|
||||||
|
if (sender === receiverID && peer.user_id !== receiverID) {
|
||||||
|
return new TelegramPeer("user", peer.user_id, args)
|
||||||
|
}
|
||||||
|
return new TelegramPeer("user", sender, args)
|
||||||
case "peerChannel":
|
case "peerChannel":
|
||||||
return new TelegramPeer("channel", peer.channel_id, {
|
return new TelegramPeer("channel", peer.channel_id, {
|
||||||
accessHash: peer.access_hash,
|
accessHash: peer.access_hash,
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
const telegram = require("telegram-mtproto")
|
const telegram = require("telegram-mtproto")
|
||||||
|
const { nextRandomInt } = require("telegram-mtproto/lib/bin")
|
||||||
const fileType = require("file-type")
|
const fileType = require("file-type")
|
||||||
const pkg = require("../package.json")
|
const pkg = require("../package.json")
|
||||||
const TelegramPeer = require("./telegram-peer")
|
const TelegramPeer = require("./telegram-peer")
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module telegram-puppet
|
* @module telegram-puppet
|
||||||
*/
|
*/
|
||||||
@@ -254,7 +254,7 @@ class TelegramPuppet {
|
|||||||
peer: peer.toInputPeer(),
|
peer: peer.toInputPeer(),
|
||||||
message,
|
message,
|
||||||
entities,
|
entities,
|
||||||
random_id: ~~(Math.random() * (1 << 30)),
|
random_id: [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
|
||||||
}
|
}
|
||||||
if (!payload.entities) {
|
if (!payload.entities) {
|
||||||
// Everything breaks if we send undefined things :/
|
// Everything breaks if we send undefined things :/
|
||||||
@@ -271,7 +271,7 @@ class TelegramPuppet {
|
|||||||
const result = await this.client("messages.sendMedia", {
|
const result = await this.client("messages.sendMedia", {
|
||||||
peer: peer.toInputPeer(),
|
peer: peer.toInputPeer(),
|
||||||
media,
|
media,
|
||||||
random_id: ~~(Math.random() * (1 << 30)),
|
random_id: [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
|
||||||
})
|
})
|
||||||
// TODO use result? (maybe the ID)
|
// TODO use result? (maybe the ID)
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user