Skip to content

Commit 3668275

Browse files
Fixed /fetch command to use new screenshot script syntax
1 parent 6a5877d commit 3668275

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

NotifierBot/Sources/Notifier/Commands/FetchCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct FetchCommand: Command {
3232
return
3333
}
3434
// Take the screenshot
35-
JFUtils.takeScreenshot(url: entry!.url, filename: "/tmp/screenshot.png", area: entry!.area)
35+
JFUtils.takeScreenshot(entry: entry!, filename: "/tmp/screenshot.png")
3636
// Send the screenshot as file
3737
// Use the script, because its easier than sending the file in swift
3838
JFUtils.sendFile(path: "/tmp/screenshot.png", chatID: chatID)

NotifierBot/Sources/Notifier/Commands/FetchURLCommand.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ struct FetchURLCommand: Command {
4040
try bot.sendMessage("Please enter a valid URL, starting with 'http://' or 'https://'", to: chatID)
4141
return
4242
}
43-
JFUtils.takeScreenshot(url: url, filename: "/tmp/screenshot.png", area: area)
43+
// Create a dummy entry for this url
44+
JFUtils.takeScreenshot(entry: URLEntry(name: "", url: url, area: area, chatID: chatID), filename: "/tmp/screenshot.png")
4445
JFUtils.sendFile(path: "/tmp/screenshot.png", chatID: chatID)
4546
}
4647
}

NotifierBot/Sources/Notifier/JFUtils.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ struct JFUtils {
3131
return output
3232
}
3333

34-
static func takeScreenshot(url: String, filename: String, area: Rectangle = .zero) {
35-
shell("\(kScreenshotScript) \(filename) \"\(url)\"")
36-
if area.width != 0 && area.height != 0 {
34+
static func takeScreenshot(entry e: URLEntry, filename: String) {
35+
shell("\(kScreenshotScript) \"\(e.url)\" \"\(filename)\" \"\(e.delay)\" \"\(e.captureElement)\" \"\(e.clickElement)\" \"\(e.waitElement)\"")
36+
if e.area.width != 0 && e.area.height != 0 {
3737
// Crop the screenshot
38-
shell("\(kConvertPath) \(filename) -crop \(area.width)x\(area.height)+\(area.x)+\(area.y) \(filename)")
38+
shell("\(kConvertPath) \(filename) -crop \(e.area.width)x\(e.area.height)+\(e.area.x)+\(e.area.y) \(filename)")
3939
}
4040
}
4141

0 commit comments

Comments
 (0)