oof
This commit is contained in:
parent
8f139417f1
commit
4a53d52bd5
|
@ -65,19 +65,21 @@ export default class tg extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async send(chatid, msg, reply = null) {
|
async send(chatid, msg, reply = null) {
|
||||||
|
msg = Array.isArray(msg) ? msg.join("\n") : msg;
|
||||||
if (msg.length === 0 || msg.length > 2048)
|
if (msg.length === 0 || msg.length > 2048)
|
||||||
return this.emit("data", ["error", "msg to short or to long lol"]);
|
return this.emit("data", ["error", "msg to short or to long lol"]);
|
||||||
const opts = {
|
const opts = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
chat_id: chatid,
|
chat_id: chatid,
|
||||||
text: msg.split("\n").length > 1 ? `<code>${msg}</code>` : msg,
|
text: this.format(msg),//msg.split("\n").length > 1 ? `<code>${this.format(msg)}</code>` : this.format(msg),
|
||||||
parse_mode: "HTML"
|
parse_mode: "HTML"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (reply)
|
if (reply)
|
||||||
opts.body.reply_to_message_id = reply;
|
opts.body.reply_to_message_id = reply;
|
||||||
await fetch(`${this.api}/sendMessage`, opts);
|
const res = await (await fetch(`${this.api}/sendMessage`, opts)).json();
|
||||||
|
console.log(res);
|
||||||
}
|
}
|
||||||
async sendmsg(mode, recipient, msg) {
|
async sendmsg(mode, recipient, msg) {
|
||||||
await this.send(recipient, msg);
|
await this.send(recipient, msg);
|
||||||
|
@ -98,9 +100,9 @@ export default class tg extends EventEmitter {
|
||||||
message: tmp.text,
|
message: tmp.text,
|
||||||
time: tmp.date,
|
time: tmp.date,
|
||||||
raw: tmp,
|
raw: tmp,
|
||||||
reply: msg => this.send(tmp.chat.id, this.format(msg), tmp.message_id),
|
reply: msg => this.send(tmp.chat.id, msg, tmp.message_id),
|
||||||
replyAction: msg => this.send(tmp.chat.id, this.format(`Uwe ${msg}`), tmp.message_id),
|
replyAction: msg => this.send(tmp.chat.id, `Uwe ${msg}`, tmp.message_id),
|
||||||
replyNotice: msg => this.send(tmp.chat.id, this.format(msg), tmp.message_id),
|
replyNotice: msg => this.send(tmp.chat.id, msg, tmp.message_id),
|
||||||
_user: this.server.user
|
_user: this.server.user
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -108,6 +110,7 @@ export default class tg extends EventEmitter {
|
||||||
return msg.toString()
|
return msg.toString()
|
||||||
.split("<").join("<")
|
.split("<").join("<")
|
||||||
.split(">").join(">")
|
.split(">").join(">")
|
||||||
|
.split("&").join("&")
|
||||||
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold
|
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold
|
||||||
.replace(/\[i\](.*?)\[\/i\]/g, "<i>$1</i>") // italic
|
.replace(/\[i\](.*?)\[\/i\]/g, "<i>$1</i>") // italic
|
||||||
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, "$2")
|
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, "$2")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user