Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.5 kB
2
Indexable
Never
    def print(self, message: str):
        if message.startswith('Watching:') or message.startswith('Earned') or message.startswith('Claim'):
            stamp = datetime.now().strftime("%X")
            if '\n' in message:
                message = message.replace('\n', f"\n{stamp}: ")
            self._text.config(state="normal", background ='green')
            self._text.insert("end", f"{stamp}: {message}\n")
            self._text.see("end")  # scroll to the newly added line
            self._text.config(state="disabled", background ='green')
        else:
            if message.startswith('Twitch is down:'):
                stamp = datetime.now().strftime("%X")
                if '\n' in message:
                    message = message.replace('\n', f"\n{stamp}: ")
                self._text.config(state="normal", background ='yellow')
                self._text.insert("end", f"{stamp}: {message}\n")
                self._text.see("end")  # scroll to the newly added line
                self._text.config(state="disabled", background ='yellow')
            else:
                stamp = datetime.now().strftime("%X")
                if '\n' in message:
                    message = message.replace('\n', f"\n{stamp}: ")
                self._text.config(state="normal", background ='red')
                self._text.insert("end", f"{stamp}: {message}\n")
                self._text.see("end")  # scroll to the newly added line
                self._text.config(state="disabled", background= 'red')
Leave a Comment