diff --git a/README.md b/README.md index 7d8e769e..bf1f136e 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ You can create different groups with separate menus, and then assign users to th ### **WORK IN PROGRESS** +- FIX: #191 No picture can be send - FEAT: #175 Copy function in Action, Renamed Switch to Toggle - FIX: #176 Error in setDynamic value - FIX: #181 Required values in setState diff --git a/src/lib/sendpic.ts b/src/lib/sendpic.ts index 36194df6..470d1af4 100644 --- a/src/lib/sendpic.ts +++ b/src/lib/sendpic.ts @@ -17,13 +17,14 @@ function sendPic( timeouts: Timeouts[], timeoutKey: string, ): Timeouts[] { - part.sendPic?.forEach((element) => { - const _this = TelegramMenu.getInstance(); - let path = ""; - if (element.id != "-") { - const url = element.id; - const newUrl = replaceAll(url, "&", "&"); - try { + try { + part.sendPic?.forEach((element) => { + const _this = TelegramMenu.getInstance(); + let path = ""; + if (element.id != "-") { + const url = element.id; + const newUrl = replaceAll(url, "&", "&"); + exec( `curl -H "Autorisation: Bearer ${token.trim()}" "${newUrl}" > ${directoryPicture}${element.fileName}`, (error: any, stdout: any, stderr: any) => { @@ -39,21 +40,16 @@ function sendPic( } }, ); - } catch (e: any) { - error([ - { text: "Error:", val: e.message }, - { text: "Stack:", val: e.stack }, - ]); - } - debug([{ text: "Delay Time:", val: element.delay }]); - timeoutKey += 1; - path = `${directoryPicture}${element.fileName}`; - return; - } - try { - path = element.fileName; + debug([{ text: "Delay Time:", val: element.delay }]); + timeoutKey += 1; + path = `${directoryPicture}${element.fileName}`; + + } else { + return + } + const timeout = _this.setTimeout(async () => { sendToTelegram(userToSend, path, undefined, instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, ""); let timeoutToClear: Timeouts[] = []; @@ -63,19 +59,21 @@ function sendPic( }); timeouts = timeouts.filter((item) => item.key !== timeoutKey); + debug([{ text: "Picture sended" }]); }, parseInt(element.delay)); if (timeout) { timeouts.push({ key: timeoutKey, timeout: timeout }); } - } catch (e: any) { - error([ - { text: "Error:", val: e.message }, - { text: "Stack:", val: e.stack }, - ]); - } - }); - debug([{ text: "Picture sended" }]); + }); + return timeouts; + + } catch (e: any) { + error([ + { text: "Error:", val: e.message }, + { text: "Stack:", val: e.stack }, + ]); + } return timeouts; }