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 58ec619
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 59 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
4 changes: 2 additions & 2 deletions admin/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { TelegramMenuApp } from "./types/props-types";

class App extends GenericApp<TelegramMenuApp.AdditionalProps, TelegramMenuApp.AdditionalState> {
dropBoxRef: Dropbox.Ref;
constructor(props: any) {
constructor(props: TelegramMenuApp.AdditionalProps) {
const extendedProps: TelegramMenuApp.ExtendedProps = {
...props,
encryptedFields: [],
Connection: AdminConnection,
Connection: {} as AdminConnection,
translations: {
en: require("../../admin/i18n/en/translations.json"),
de: require("../../admin/i18n/de/translations.json"),
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.

52 changes: 24 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, "&amp;", "&");
try {
try {
part.sendPic?.forEach((element) => {
const _this = TelegramMenu.getInstance();
let path = "";
if (element.id != "-") {
const url = element.id;
const newUrl = replaceAll(url, "&amp;", "&");

exec(
`curl -H "Autorisation: Bearer ${token.trim()}" "${newUrl}" > ${directoryPicture}${element.fileName}`,
(error: any, stdout: any, stderr: any) => {
Expand All @@ -39,21 +40,15 @@ 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}`;
debug([{ text: "Path : ", val: path }]);
} 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 +58,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 58ec619

Please sign in to comment.