Browse Source

Change all fmt.Println to log.Println

Toni Fadjukoff 6 years ago
parent
commit
7f454cb777
1 changed files with 11 additions and 11 deletions
  1. 11 11
      bot.go

+ 11 - 11
bot.go View File

90
 
90
 
91
 			if false {
91
 			if false {
92
 				// Stub
92
 				// Stub
93
-				fmt.Println("Pretend to update wiki text to ", updateTitle, section.index, changedWikiText,
93
+				log.Println("Pretend to update wiki text to ", updateTitle, section.index, changedWikiText,
94
 					fmt.Sprintf("Added %s song for %s", updateSection, author))
94
 					fmt.Sprintf("Added %s song for %s", updateSection, author))
95
 				return true, nil
95
 				return true, nil
96
 			}
96
 			}
117
 	for _, entry := range entries {
117
 	for _, entry := range entries {
118
 		song := songWikiText(entry.spotifyURL, entry.artist, entry.title)
118
 		song := songWikiText(entry.spotifyURL, entry.artist, entry.title)
119
 
119
 
120
-		fmt.Println("Time has passed for " + song)
120
+		log.Println("Time has passed for " + song)
121
 
121
 
122
 		success, err := app.AddSong(entry.article, entry.section, entry.username, song)
122
 		success, err := app.AddSong(entry.article, entry.section, entry.username, song)
123
 		if err != nil {
123
 		if err != nil {
126
 		if success {
126
 		if success {
127
 			err = app.SongSynced(entry.userId, entry.roundId)
127
 			err = app.SongSynced(entry.userId, entry.roundId)
128
 			if err != nil {
128
 			if err != nil {
129
-				fmt.Println("Error received:", err)
129
+				log.Println("Error received:", err)
130
 			}
130
 			}
131
 		}
131
 		}
132
 	}
132
 	}
147
 	if score == "" {
147
 	if score == "" {
148
 		return score
148
 		return score
149
 	}
149
 	}
150
-	rating, _ := regexp.Compile("^\\{\\{Rating\\|\\d([.,]\\d)\\|5\\}\\}?$")
150
+	rating, _ := regexp.Compile("^\\{\\{Rating\\|\\d([.,]\\d)?\\|5\\}\\}$")
151
 	if rating.MatchString(score) {
151
 	if rating.MatchString(score) {
152
 		score = strings.Replace(score, "{{Rating|", "", 1)
152
 		score = strings.Replace(score, "{{Rating|", "", 1)
153
 		score = strings.Replace(score, "|5}}", "", 1)
153
 		score = strings.Replace(score, "|5}}", "", 1)
176
 	if thirdQuarterScore.MatchString(score) {
176
 	if thirdQuarterScore.MatchString(score) {
177
 		return fmt.Sprintf("%c.75", score[0])
177
 		return fmt.Sprintf("%c.75", score[0])
178
 	}
178
 	}
179
-	fmt.Printf("Could not match '%s'\n", score)
179
+	log.Printf("Could not match '%s'\n", score)
180
 	return ""
180
 	return ""
181
 }
181
 }
182
 
182
 
215
 			newLine := "| " + AVERAGE_MARK + " " + expression
215
 			newLine := "| " + AVERAGE_MARK + " " + expression
216
 			changedLines = append(changedLines, newLine)
216
 			changedLines = append(changedLines, newLine)
217
 			if newLine != line {
217
 			if newLine != line {
218
-				fmt.Printf("Difference for %s\n%s\n%s\n", currentAuthor, newLine, line)
218
+				log.Printf("Difference for %s\n%s\n%s\n", currentAuthor, newLine, line)
219
 			}
219
 			}
220
 
220
 
221
 		} else {
221
 		} else {
256
 			}
256
 			}
257
 		}
257
 		}
258
 	}
258
 	}
259
-	fmt.Printf("Found playlist %s and tracks %s\n", playlistId, tracks)
259
+	log.Printf("Found playlist %s and tracks %s\n", playlistId, tracks)
260
 
260
 
261
 	return playlistId, tracks
261
 	return playlistId, tracks
262
 }
262
 }
288
 			if weekNumber > currentWeek {
288
 			if weekNumber > currentWeek {
289
 				break
289
 				break
290
 			}
290
 			}
291
-			fmt.Println("Checking section", section.title)
291
+			log.Println("Checking section", section.title)
292
 
292
 
293
 			wikiText, err := wiki.GetWikiPageSectionText(title, section.index)
293
 			wikiText, err := wiki.GetWikiPageSectionText(title, section.index)
294
 			if err != nil {
294
 			if err != nil {
347
 func (app *App) AutomateSectionTask() {
347
 func (app *App) AutomateSectionTask() {
348
 	panels, err := app.db.FindAllPanels()
348
 	panels, err := app.db.FindAllPanels()
349
 	if err != nil {
349
 	if err != nil {
350
-		fmt.Println("Error while checking db for panels:", err)
350
+		log.Println("Error while checking db for panels:", err)
351
 		return
351
 		return
352
 	}
352
 	}
353
 	for _, panel := range panels {
353
 	for _, panel := range panels {
354
-		fmt.Println("Checking panel", panel)
354
+		log.Println("Checking panel", panel)
355
 		err := app.AutomateSection(panel)
355
 		err := app.AutomateSection(panel)
356
 		if err != nil {
356
 		if err != nil {
357
-			fmt.Println("Error while processing panel:", err)
357
+			log.Println("Error while processing panel:", err)
358
 		}
358
 		}
359
 	}
359
 	}
360
 
360