-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
147 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const axios = require("axios"); | ||
const { sendToTelegram } = require("./telegram"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
async function httpRequest(_this, parts, userToSend, instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, directoryPicture) { | ||
parts.httpRequest.forEach((part) => { | ||
const url = part.url; | ||
const user = part.user; | ||
const password = part.password; | ||
const method = "get"; | ||
|
||
axios( | ||
user | ||
? { | ||
method: method, | ||
url: url, | ||
responseType: "arraybuffer", | ||
auth: { | ||
username: user, | ||
password: password, | ||
}, | ||
} | ||
: { | ||
method: method, | ||
url: url, | ||
responseType: "arraybuffer", | ||
}, | ||
) | ||
.then(function (response) { | ||
const imagePath = path.join(directoryPicture, part.filename); | ||
try { | ||
fs.writeFileSync(imagePath, Buffer.from(response.data), "binary"); | ||
_this.log.debug("Bild erfolgreich gespeichert:", imagePath); | ||
} catch (error) { | ||
_this.log.error("Fehler beim Speichern des Bildes:", error); | ||
} | ||
|
||
// Hier könntest du weitere Aktionen durchführen, z.B. iobroker-Objekt aktualisieren | ||
setTimeout(() => { | ||
sendToTelegram(_this, user, imagePath, [], instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, ""); | ||
}, part.delay); | ||
}) | ||
.catch(function (response) { | ||
//handle error | ||
console.log(response); | ||
// sendToTelegram(_this, userToSend, response, [], instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, ""); | ||
}); | ||
}); | ||
return true; | ||
} | ||
module.exports = { | ||
httpRequest, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.