def send_recent_files(self, window: tk.Tk): """Send only the files of today""" files = list(Parser.gsf_combatlogs()) result = list() for file in files: file_date = Parser.parse_filename(file) if file_date is None: continue file_date = file_date.date() if file_date == datetime.now().date(): result.append(file) self.send_files(window, result)
def send_files(self, window: tk.Tk, files: list = None): """ Send the match data found in CombatLogs in the CombatLogs folder to the Discord Bot Server. For the actual sending, the send_file function is used to send each individual file. If Discord Sharing is not enabled, the function returns immediately. This function is meant to be executed during start-up of the GSF Parser, while still at the SplashScreen. The procedure of this function takes a rather long time and given data access of the MainWindow.characters_frame running it in a separate Thread would be a bad idea, and thus this function would interrupt the mainloop for at least three seconds, if no files have to be synchronized. If files have to be synchronized, this function will take long to complete. """ if os.path.exists("development"): return splash = DiscordSplash(window.splash if window.splash is not None else window) splash.update_state() if settings["sharing"]["enabled"] is False or self.validate_tag(settings["sharing"]["discord"]) is False: return files = list(Parser.gsf_combatlogs()) if files is None else files if len(self.db) == 0: mb.showinfo("Notice", "This is the first time data is being synchronized with the Discord Bot Server. " "This may take a while.") elif len(files) - len(self.db) > 10: mb.showinfo("Notice", "There are quite many files to synchronize. Please stand by.") print("[DiscordClient] Initiating sending of match data of {} CombatLogs".format(len(files))) for file_name in files: try: self.send_file(file_name, window) except Exception: mb.showerror("Error", "There was an error processing {}.".format(file_name)) splash.update_state() if self.failed > 5: break splash.destroy() print("[DiscordClient] Done sending files.")