File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
NotifierBot/Sources/Notifier/Commands Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,13 @@ struct DiffCommand: Command {
2626 let name = args. joined ( separator: " " )
2727 // Check if an entry with this name exists
2828 let config = try ConfigParser . getConfig ( )
29- guard config. contains ( where: { $0. name. lowercased ( ) == name. lowercased ( ) && $0. chatID == chatID } ) else {
29+ guard let entry = config. first ( where: { $0. name. lowercased ( ) == name. lowercased ( ) && $0. chatID == chatID } ) else {
3030 try bot. sendMessage ( " There is no entry with the name ' \( name) ' " , to: chatID)
3131 return
3232 }
33+ let realName = entry. name
3334 // Send the diff file and the contents of the ncc file
34- let nccInfo = try String ( contentsOfFile: " \( mainDirectory!) /urlwatcher/images/ \( name ) / \( nccFile) " )
35- JFUtils . sendImage ( path: " \( mainDirectory!) /urlwatcher/images/ \( name ) / \( diffFile) " , chatID: chatID, text: nccInfo)
35+ let nccInfo = try ? String ( contentsOfFile: " \( mainDirectory!) /urlwatcher/images/ \( realName ) / \( nccFile) " )
36+ JFUtils . sendImage ( path: " \( mainDirectory!) /urlwatcher/images/ \( realName ) / \( diffFile) " , chatID: chatID, text: nccInfo)
3637 }
3738}
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ function screenshotsMatch {
135135
136136 if [ " NCC" -lt " $NCC_THRESHOLD " ]; then
137137 # The screenshots do not match. The website has changed
138+
138139 # Write detailed NCC information to a file (and don't overwrite the diff file)
139140 compare -verbose -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null > " $NCC_FILE "
140141
@@ -144,6 +145,9 @@ function screenshotsMatch {
144145 fi
145146 fi
146147
148+ # Write detailed NCC information to a file (and don't overwrite the diff file)
149+ compare -verbose -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null > " $NCC_FILE "
150+
147151 # If statement above didn't exit, that means we have no mismatching hashes and therefore the screenshots match (return true)
148152 # In bash: 0 == true
149153 return 0
@@ -224,7 +228,7 @@ while IFS='' read -r line || [ -n "${line}" ]; do
224228
225229 # If the new screenshot is all black or all white (some display error), ignore it
226230 mean=$( convert latest.png -format " %[mean]" info:)
227- if [ " $mean " == " 0" || " $mean " == " 65535" ]; then
231+ if [ " $mean " == " 0" ] || [ " $mean " == " 65535" ]; then
228232 rollBack
229233 # Skip this entry
230234 cd ../..
You can’t perform that action at this time.
0 commit comments