Chrome screenshots can be saved for the human
This commit is contained in:
@@ -139,10 +139,14 @@ func captureTool(_ args: [String: Any]) async throws -> [Content] {
|
||||
guard args.bool("save") else {
|
||||
return [.text(shot.note), .png(shot.png)]
|
||||
}
|
||||
return [.text("\(shot.note); saved to \(try save(shot.png))"), .png(shot.png)]
|
||||
}
|
||||
|
||||
func save(_ png: Data) throws -> String {
|
||||
guard let dir = mediaDir else {
|
||||
throw ToolError("save needs byre's media folder, and this byre-hands has none")
|
||||
}
|
||||
let url = URL(filePath: dir).appending(path: "capture-\(UUID().uuidString.prefix(8).lowercased()).png")
|
||||
try shot.png.write(to: url)
|
||||
return [.text("\(shot.note); saved to \(url.path)"), .png(shot.png)]
|
||||
try png.write(to: url)
|
||||
return url.path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user