Skip to content

Commit

Permalink
FIX: #191 No picture can be send
Browse files Browse the repository at this point in the history
  • Loading branch information
MiRo1310 committed Oct 14, 2024
1 parent f83b282 commit ad4e1f1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 57 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 21 additions & 27 deletions build/lib/sendpic.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/lib/sendpic.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 23 additions & 28 deletions src/lib/sendpic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -39,21 +40,14 @@ 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;
}
debug([{ text: "Delay Time:", val: element.delay }]);
timeoutKey += 1;
path = `${directoryPicture}${element.fileName}`;
} else {
return;
}

try {
path = element.fileName;
const timeout = _this.setTimeout(async () => {
sendToTelegram(userToSend, path, undefined, instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, "");
let timeoutToClear: Timeouts[] = [];
Expand All @@ -63,19 +57,20 @@ 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;
}

Expand Down

0 comments on commit ad4e1f1

Please sign in to comment.