From 1b81d8d9ee5e202c25d83b9942f0358820a8ce0e Mon Sep 17 00:00:00 2001 From: anoviel Date: Wed, 3 Feb 2021 20:46:53 +0100 Subject: [PATCH] changed format with pre_commit hook --- .gitignore | 2 +- .../TwitchChannelPointsMiner.py | 2 +- TwitchChannelPointsMiner/classes/TwitchChat.py | 10 ++++++---- TwitchChannelPointsMiner/classes/entities/Chat.py | 11 ++++++----- .../classes/entities/Streamer.py | 15 ++++++++++----- example.py | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 0a444db..360b9f1 100644 --- a/.gitignore +++ b/.gitignore @@ -145,4 +145,4 @@ chromedriver* cookies/* logs/* screenshots/* -htmls/* \ No newline at end of file +htmls/* diff --git a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py index 6f2848e..ea2fdcc 100644 --- a/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py +++ b/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py @@ -261,7 +261,7 @@ class TwitchChannelPointsMiner: self.twitch_browser.browser.quit() for streamer in self.streamers: - if(streamer is not None): + if streamer is not None: streamer.leave_chat() self.running = self.twitch.running = False diff --git a/TwitchChannelPointsMiner/classes/TwitchChat.py b/TwitchChannelPointsMiner/classes/TwitchChat.py index 2d057dd..e0a0bfa 100644 --- a/TwitchChannelPointsMiner/classes/TwitchChat.py +++ b/TwitchChannelPointsMiner/classes/TwitchChat.py @@ -1,10 +1,11 @@ import logging - -from TwitchChannelPointsMiner.classes.entities.Chat import Chat from multiprocessing import Process +from TwitchChannelPointsMiner.classes.entities.Chat import Chat + logger = logging.getLogger(__name__) + class ChatSettings(object): def __init__( self, @@ -14,6 +15,7 @@ class ChatSettings(object): self.username = username self.token = token + class TwitchChat(Process): def __deepcopy__(self, memo): return None @@ -27,7 +29,7 @@ class TwitchChat(Process): def run(self): # Create IRC bot connection try: - IRC = Chat( self.username, self.token, self.channel ) + IRC = Chat(self.username, self.token, self.channel) IRC.start() except KeyboardInterrupt: - None # dont handle KeyboardInterruption here + None # dont handle KeyboardInterruption here diff --git a/TwitchChannelPointsMiner/classes/entities/Chat.py b/TwitchChannelPointsMiner/classes/entities/Chat.py index 3b58535..9263fe1 100644 --- a/TwitchChannelPointsMiner/classes/entities/Chat.py +++ b/TwitchChannelPointsMiner/classes/entities/Chat.py @@ -1,16 +1,17 @@ - import irc.bot + class Chat(irc.bot.SingleServerIRCBot): def __init__(self, username, token, channel): self.token = token - self.channel = '#' + channel + self.channel = "#" + channel # Create IRC bot connection - server = 'irc.chat.twitch.tv' + server = "irc.chat.twitch.tv" port = 6667 - irc.bot.SingleServerIRCBot.__init__(self, [(server, port, 'oauth:'+token)], username, username) - + irc.bot.SingleServerIRCBot.__init__( + self, [(server, port, "oauth:" + token)], username, username + ) def on_welcome(self, c, e): # You must request specific capabilities before you can use them diff --git a/TwitchChannelPointsMiner/classes/entities/Streamer.py b/TwitchChannelPointsMiner/classes/entities/Streamer.py index 6f93356..ab386e5 100644 --- a/TwitchChannelPointsMiner/classes/entities/Streamer.py +++ b/TwitchChannelPointsMiner/classes/entities/Streamer.py @@ -1,15 +1,16 @@ import logging import time -from TwitchChannelPointsMiner.classes.TwitchChat import TwitchChat, ChatSettings from TwitchChannelPointsMiner.classes.entities.Bet import BetSettings from TwitchChannelPointsMiner.classes.entities.Stream import Stream from TwitchChannelPointsMiner.classes.Settings import Settings +from TwitchChannelPointsMiner.classes.TwitchChat import ChatSettings, TwitchChat from TwitchChannelPointsMiner.constants.twitch import URL from TwitchChannelPointsMiner.utils import _millify logger = logging.getLogger(__name__) + class StreamerSettings(object): def __init__( self, @@ -18,7 +19,7 @@ class StreamerSettings(object): claim_drops: bool = None, watch_streak: bool = None, bet: BetSettings = None, - chat_client: ChatSettings = None + chat_client: ChatSettings = None, ): self.make_predictions = make_predictions self.follow_raid = follow_raid @@ -108,11 +109,15 @@ class Streamer(object): return self.stream_up == 0 or ((time.time() - self.stream_up) > 120) def leave_chat(self): - if(self.chat is not None): + if self.chat is not None: self.chat.terminate() def join_chat(self): - if(self.settings.chat_client is not None): - self.chat = TwitchChat(self.settings.chat_client.username, self.settings.chat_client.token, self.username) + if self.settings.chat_client is not None: + self.chat = TwitchChat( + self.settings.chat_client.username, + self.settings.chat_client.token, + self.username, + ) logger.info(f"Connecting to {self.username}'s chat!") self.chat.start() diff --git a/example.py b/example.py index 659f696..bbcd75b 100644 --- a/example.py +++ b/example.py @@ -68,4 +68,4 @@ def main(): ) if __name__ == "__main__": - main() \ No newline at end of file + main()