- Inserire l'immagine degli annunci sul bot Telegram
This commit is contained in:
@@ -752,7 +752,7 @@ const MyTelegramBot = {
|
||||
|
||||
local_sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text,
|
||||
message_id, chat_id, ripr_menuPrec,
|
||||
MyForm = null) {
|
||||
MyForm = null, img = '') {
|
||||
|
||||
if (!idtelegram)
|
||||
return { text: '' };
|
||||
@@ -761,7 +761,7 @@ const MyTelegramBot = {
|
||||
if (cl && idtelegram) {
|
||||
|
||||
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
chat_id, ripr_menuPrec);
|
||||
chat_id, ripr_menuPrec, img);
|
||||
}
|
||||
|
||||
return { text: '' };
|
||||
@@ -1302,7 +1302,7 @@ const MyTelegramBot = {
|
||||
|
||||
sendMsgTelegramByIdTelegram: async function (
|
||||
idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
|
||||
MyForm = null) {
|
||||
MyForm = null, img = '') {
|
||||
|
||||
if (!idtelegram)
|
||||
return;
|
||||
@@ -1312,7 +1312,7 @@ const MyTelegramBot = {
|
||||
let myform = null;
|
||||
|
||||
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
chat_id, ripr_menuPrec);
|
||||
chat_id, ripr_menuPrec, img);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -1372,6 +1372,7 @@ const MyTelegramBot = {
|
||||
//const rismsg =
|
||||
params.content = eventobj.newdescr;
|
||||
params.title = '';
|
||||
params.img = eventobj.img;
|
||||
invia = true;
|
||||
}
|
||||
}
|
||||
@@ -3882,21 +3883,41 @@ class Telegram {
|
||||
},
|
||||
};
|
||||
}
|
||||
return this.bot.sendMessage(id, text, form).catch((e) => {
|
||||
let blocked = false;
|
||||
if ((e.message.indexOf('Forbidden') > 0) ||
|
||||
(e.message.indexOf('chat not found') > 0)) {
|
||||
blocked = true;
|
||||
}
|
||||
if (!blocked) {
|
||||
console.error(e.message);
|
||||
}
|
||||
if (blocked) {
|
||||
User.SetTelegramWasBlocked(this.idapp, id);
|
||||
// ++Todo: DA FARE ! local_sendMsgTelegramToTheManagers(this.idapp, addtext + text);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
if (opt && opt.img) {
|
||||
return this.bot.sendPhoto(id, opt.img, { caption: text, ...form }).catch((e) => {
|
||||
let blocked = false;
|
||||
if ((e.message.indexOf('Forbidden') > 0) ||
|
||||
(e.message.indexOf('chat not found') > 0)) {
|
||||
blocked = true;
|
||||
}
|
||||
if (!blocked) {
|
||||
console.error(e.message);
|
||||
}
|
||||
if (blocked) {
|
||||
User.SetTelegramWasBlocked(this.idapp, id);
|
||||
// ++Todo: DA FARE ! local_sendMsgTelegramToTheManagers(this.idapp, addtext + text);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
return this.bot.sendMessage(id, text, form).catch((e) => {
|
||||
let blocked = false;
|
||||
if ((e.message.indexOf('Forbidden') > 0) ||
|
||||
(e.message.indexOf('chat not found') > 0)) {
|
||||
blocked = true;
|
||||
}
|
||||
if (!blocked) {
|
||||
console.error(e.message);
|
||||
}
|
||||
if (blocked) {
|
||||
User.SetTelegramWasBlocked(this.idapp, id);
|
||||
// ++Todo: DA FARE ! local_sendMsgTelegramToTheManagers(this.idapp, addtext + text);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e, 'text', text);
|
||||
return 0;
|
||||
@@ -3922,7 +3943,7 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
async sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec) {
|
||||
async sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec, img = '') {
|
||||
|
||||
if (!id || !text)
|
||||
return false;
|
||||
@@ -3932,12 +3953,12 @@ class Telegram {
|
||||
let text1 = text.slice(0, 4090);
|
||||
let text2 = text.slice(4090, text.length);
|
||||
await this._inviaMsg(id, text1, form, menu, msg_id, chat_id,
|
||||
ripr_menuPrec);
|
||||
ripr_menuPrec, { img });
|
||||
return await this._inviaMsg(id, text2, form, menu, msg_id, chat_id,
|
||||
ripr_menuPrec);
|
||||
ripr_menuPrec, { img });
|
||||
} else {
|
||||
return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
|
||||
ripr_menuPrec);
|
||||
ripr_menuPrec, { img });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error sendMsg', e);
|
||||
|
||||
Reference in New Issue
Block a user