From e8196bdcfd64e68c87fe8eae3e94d5b5687cb217 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Tue, 31 May 2022 15:54:14 +0000 Subject: [PATCH] changed logging method; used black formatter globally --- skgyorugo/analyze_auto_message.py | 9 ---- skgyorugo/analyze_command.py | 32 +++++------- skgyorugo/auto_messages/hello1.py | 1 - skgyorugo/auto_messages/youtube.py | 2 +- skgyorugo/commands/addaccount.py | 9 ---- skgyorugo/commands/addcommand.py | 30 +++++------ skgyorugo/commands/cleanqueue.py | 9 ---- skgyorugo/commands/coin.py | 15 ++++-- skgyorugo/commands/commands.py | 12 ++--- skgyorugo/commands/delete.py | 4 +- skgyorugo/commands/editcommand.py | 28 ++++------ skgyorugo/commands/emotes.py | 4 +- skgyorugo/commands/forcehere.py | 9 ---- skgyorugo/commands/forcejoin.py | 9 ---- skgyorugo/commands/forceleave.py | 9 ---- skgyorugo/commands/forcenothere.py | 9 ---- skgyorugo/commands/here.py | 9 ---- skgyorugo/commands/join.py | 9 ---- skgyorugo/commands/latege.py | 8 +-- skgyorugo/commands/leave.py | 9 ---- skgyorugo/commands/movedown.py | 9 ---- skgyorugo/commands/moveup.py | 9 ---- skgyorugo/commands/newteams.py | 9 ---- skgyorugo/commands/nothere.py | 9 ---- skgyorugo/commands/opgg.py | 9 ---- skgyorugo/commands/queue.py | 9 ---- skgyorugo/commands/removecommand.py | 25 +++------ skgyorugo/commands/scam.py | 2 +- skgyorugo/commands/spam.py | 4 +- skgyorugo/commands/t.py | 4 +- skgyorugo/commands/teams.py | 9 ---- skgyorugo/commands/teamsize.py | 9 ---- skgyorugo/commands/uwu.py | 30 ++++++----- skgyorugo/commands/youtube.py | 4 +- skgyorugo/database_manager.py | 60 +++++++++++----------- skgyorugo/lol_api/match_v5.py | 11 ---- skgyorugo/lol_api/spectator_v4.py | 9 ---- skgyorugo/lol_api/summoner_v4.py | 19 +++---- skgyorugo/main.py | 13 ++--- skgyorugo/requirements.txt | 43 ++++++++++------ skgyorugo/scripts/alwase.py | 7 ++- skgyorugo/scripts/chatting.py | 6 +-- skgyorugo/scripts/clean_queue.py | 9 ---- skgyorugo/scripts/unit_converter.py | 10 ++-- skgyorugo/tools/smart_start_stream_time.py | 13 +---- skgyorugo/variable_manager/parser.py | 6 +-- skgyorugo/yt_api/videos.py | 8 ++- 47 files changed, 179 insertions(+), 402 deletions(-) diff --git a/skgyorugo/analyze_auto_message.py b/skgyorugo/analyze_auto_message.py index 5caed27..aa8ef11 100644 --- a/skgyorugo/analyze_auto_message.py +++ b/skgyorugo/analyze_auto_message.py @@ -11,15 +11,6 @@ reload(tools.smart_privmsg) reload(tools.smart_start_stream_time) logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PATH = os.path.dirname(os.path.realpath(__file__)) logger.debug(f"analyze_auto_message PATH set to: {PATH}") diff --git a/skgyorugo/analyze_command.py b/skgyorugo/analyze_command.py index fe8bb12..76ba314 100644 --- a/skgyorugo/analyze_command.py +++ b/skgyorugo/analyze_command.py @@ -7,15 +7,6 @@ import logging from aptbot.bot import Bot, Message, Commands logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler('/var/log/aptbot/logs.log') -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PATH = os.path.dirname(os.path.realpath(__file__)) logger.debug(f"PATH set to: {PATH}") @@ -33,9 +24,9 @@ def do_command(bot: Bot, message: Message, command_modules: dict): replied_message = None if replied_message: - command = message.value.split(' ')[1] + command = message.value.split(" ")[1] else: - command = message.value.split(' ')[0] + command = message.value.split(" ")[0] prefix = command[0] command = command[1:] user_id = message.tags["user-id"] @@ -77,23 +68,26 @@ def do_command(bot: Bot, message: Message, command_modules: dict): command, prefix, user_perm, - ) + ), ) fetched = c.fetchall() if not fetched: conn.close() return - (_, value, - command_user_cooldown, - command_global_cooldown, - avail_time) = random.choice(fetched) + ( + _, + value, + command_user_cooldown, + command_global_cooldown, + avail_time, + ) = random.choice(fetched) if message_timestamp < avail_time: bot.send_privmsg( message.channel, f"The command '{prefix}{command}' is on cooldown. \ - Please wait {int(avail_time - message_timestamp) + 1} seconds." + Please wait {int(avail_time - message_timestamp) + 1} seconds.", ) conn.close() return @@ -104,14 +98,14 @@ def do_command(bot: Bot, message: Message, command_modules: dict): user_id, command, command_user_cooldown + message_timestamp, - ) + ), ) c.execute( "UPDATE commands SET last_used = ? WHERE command = ?", ( message_timestamp, command, - ) + ), ) conn.commit() conn.close() diff --git a/skgyorugo/auto_messages/hello1.py b/skgyorugo/auto_messages/hello1.py index 939eb8e..78bfe96 100644 --- a/skgyorugo/auto_messages/hello1.py +++ b/skgyorugo/auto_messages/hello1.py @@ -7,4 +7,3 @@ END_TIME = 0.5 * 60 * 60 def main(bot: Bot, message: Message): msg = "peepoWave" bot.send_privmsg(message.channel, msg) - diff --git a/skgyorugo/auto_messages/youtube.py b/skgyorugo/auto_messages/youtube.py index 53ca354..426f9fb 100644 --- a/skgyorugo/auto_messages/youtube.py +++ b/skgyorugo/auto_messages/youtube.py @@ -11,7 +11,7 @@ def main(bot: Bot, message: Message): video = yt_api.videos.get_newest_video(CHANNEL_ID) if video: video_link = f"https://www.youtube.com/watch?v={video.video_id}" - msg = f"Watch Peks' latest video \"{video.video_name}\" here: {video_link}" + msg = f'Watch Peks\' latest video "{video.video_name}" here: {video_link}' else: msg = f"Check out my youtube channel here -> https://www.youtube.com/channel/{CHANNEL_ID}" bot.send_privmsg(message.channel, msg) diff --git a/skgyorugo/commands/addaccount.py b/skgyorugo/commands/addaccount.py index ffccbb1..69cdfb2 100644 --- a/skgyorugo/commands/addaccount.py +++ b/skgyorugo/commands/addaccount.py @@ -6,15 +6,6 @@ import lol_api.summoner_v4 import ttv_api.users logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 diff --git a/skgyorugo/commands/addcommand.py b/skgyorugo/commands/addcommand.py index 5df96e6..f430b46 100644 --- a/skgyorugo/commands/addcommand.py +++ b/skgyorugo/commands/addcommand.py @@ -3,7 +3,7 @@ import sqlite3 import os PERMISSION = 10 -PREFIX = '\\' +PREFIX = "\\" DESCRIPTION = "" USER_COOLDOWN = 0 GLOBAL_COOLDOWN = 0 @@ -19,15 +19,15 @@ DEFAULT_LAST_USED = 0 def main(bot: Bot, message: Message): - msg = ' '.join(message.value.split(' ')[1:]) - command = msg.split(' ')[0] + msg = " ".join(message.value.split(" ")[1:]) + command = msg.split(" ")[0] command_prefix = command[0] command_name = command[1:] - command_value = msg = ' '.join(msg.split(' ')[1:]) - if command_prefix != '?': + command_value = msg = " ".join(msg.split(" ")[1:]) + if command_prefix != "?": bot.send_privmsg( message.channel, - f"{message.nick} you cannot use {command_prefix} as a prefix" + f"{message.nick} you cannot use {command_prefix} as a prefix", ) return @@ -38,13 +38,13 @@ def main(bot: Bot, message: Message): ( command_name, command_prefix, - ) + ), ) try: if not c.fetchone()[0]: bot.send_privmsg( message.channel, - f"The command {command_prefix}{command_name} already exists" + f"The command {command_prefix}{command_name} already exists", ) return except TypeError: @@ -60,15 +60,12 @@ def main(bot: Bot, message: Message): DEFAULT_USER_COOLDOWN, DEFAULT_GLOBAL_COOLDOWN, DEFAULT_LAST_USED, - ) + ), ) except sqlite3.IntegrityError: pass except Exception as e: - bot.send_privmsg( - message.channel, - f"There was an error adding the command: {e}" - ) + bot.send_privmsg(message.channel, f"There was an error adding the command: {e}") conn.close() return c.execute( @@ -76,11 +73,8 @@ def main(bot: Bot, message: Message): ( command_name, command_value, - ) - ) - bot.send_privmsg( - message.channel, - f"Successfully added {command_name}." + ), ) + bot.send_privmsg(message.channel, f"Successfully added {command_name}.") conn.commit() conn.close() diff --git a/skgyorugo/commands/cleanqueue.py b/skgyorugo/commands/cleanqueue.py index 340ee6b..b94131b 100644 --- a/skgyorugo/commands/cleanqueue.py +++ b/skgyorugo/commands/cleanqueue.py @@ -6,15 +6,6 @@ import sqlite3 import time logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/coin.py b/skgyorugo/commands/coin.py index 7fca71a..8c16940 100644 --- a/skgyorugo/commands/coin.py +++ b/skgyorugo/commands/coin.py @@ -3,8 +3,10 @@ import tools.smart_privmsg import random PERMISSION = 99 -PREFIX = '?' -DESCRIPTION = r"Tosses a coin, there's a 50% chance it's heads and a 50% chance it's tails" +PREFIX = "?" +DESCRIPTION = ( + r"Tosses a coin, there's a 50% chance it's heads and a 50% chance it's tails" +) USER_COOLDOWN = 10 GLOBAL_COOLDOWN = 5 @@ -12,10 +14,13 @@ GLOBAL_COOLDOWN = 5 def main(bot: Bot, message: Message): r = random.random() if r < 0.02: - tools.smart_privmsg.send(bot, message, f"the coin landed on it's side, try again.", reply=message.tags["id"]) + tools.smart_privmsg.send( + bot, + message, + f"the coin landed on it's side, try again.", + reply=message.tags["id"], + ) elif r < 0.51: tools.smart_privmsg.send(bot, message, f"heads", reply=message.tags["id"]) else: tools.smart_privmsg.send(bot, message, f"tails", reply=message.tags["id"]) - - diff --git a/skgyorugo/commands/commands.py b/skgyorugo/commands/commands.py index 8de41a1..2c62bbe 100644 --- a/skgyorugo/commands/commands.py +++ b/skgyorugo/commands/commands.py @@ -5,7 +5,7 @@ import sqlite3 import os PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 30 GLOBAL_COOLDOWN = 15 @@ -19,15 +19,11 @@ def main(bot: Bot, message: Message): conn = sqlite3.connect(os.path.join(PATH, "database.db")) c = conn.cursor() - user_perm = tools.permissions.get_permission_from_id( - message.tags["user-id"] - ) + user_perm = tools.permissions.get_permission_from_id(message.tags["user-id"]) c.execute( "SELECT prefix, command FROM commands WHERE permission >= ? ORDER BY permission ASC", - ( - user_perm, - ) + (user_perm,), ) fetched_commands = c.fetchall() @@ -39,5 +35,5 @@ def main(bot: Bot, message: Message): for command in fetched_commands: commands.append(f"{command[0]}{command[1]}") - commands = ' '.join(commands) + commands = " ".join(commands) tools.smart_privmsg.send(bot, message, commands) diff --git a/skgyorugo/commands/delete.py b/skgyorugo/commands/delete.py index 936cde6..05a8c75 100644 --- a/skgyorugo/commands/delete.py +++ b/skgyorugo/commands/delete.py @@ -1,11 +1,12 @@ from aptbot.bot import Message, Commands, Bot PERMISSION = 10 -PREFIX = '\\' +PREFIX = "\\" DESCRIPTION = "Reply to a message with \\delete to delete that message" USER_COOLDOWN = 0 GLOBAL_COOLDOWN = 0 + def main(bot: Bot, message: Message): try: replied_msg_id = message.tags["reply-parent-msg-id"] @@ -13,4 +14,3 @@ def main(bot: Bot, message: Message): return delete = f"/delete {replied_msg_id}" bot.send_privmsg(message.channel, delete) - diff --git a/skgyorugo/commands/editcommand.py b/skgyorugo/commands/editcommand.py index adee4c8..86a98de 100644 --- a/skgyorugo/commands/editcommand.py +++ b/skgyorugo/commands/editcommand.py @@ -3,7 +3,7 @@ import sqlite3 import os PERMISSION = 10 -PREFIX = '\\' +PREFIX = "\\" DESCRIPTION = "" USER_COOLDOWN = 0 GLOBAL_COOLDOWN = 0 @@ -14,15 +14,15 @@ PATH = os.path.join(COMMANDS_PATH, "..") def main(bot: Bot, message: Message): - msg = ' '.join(message.value.split(' ')[1:]) - command = msg.split(' ')[0] + msg = " ".join(message.value.split(" ")[1:]) + command = msg.split(" ")[0] command_prefix = command[0] command_name = command[1:] - command_value = msg = ' '.join(msg.split(' ')[1:]) - if command_prefix != '?': + command_value = msg = " ".join(msg.split(" ")[1:]) + if command_prefix != "?": bot.send_privmsg( message.channel, - f"{message.nick} you cannot use {command_prefix} as a prefix" + f"{message.nick} you cannot use {command_prefix} as a prefix", ) return @@ -33,12 +33,12 @@ def main(bot: Bot, message: Message): ( command_name, command_prefix, - ) + ), ) if not c.fetchone()[0]: bot.send_privmsg( message.channel, - f"The command {command_prefix}{command_name} cannot be edited" + f"The command {command_prefix}{command_name} cannot be edited", ) return @@ -48,17 +48,11 @@ def main(bot: Bot, message: Message): ( command_value, command_name, - ) + ), ) except sqlite3.IntegrityError: - bot.send_privmsg( - message.channel, - f"The command {command_name} doesn't exist." - ) + bot.send_privmsg(message.channel, f"The command {command_name} doesn't exist.") else: - bot.send_privmsg( - message.channel, - f"Successfully updated {command_name}." - ) + bot.send_privmsg(message.channel, f"Successfully updated {command_name}.") conn.commit() conn.close() diff --git a/skgyorugo/commands/emotes.py b/skgyorugo/commands/emotes.py index fe28f23..fe6f8f9 100644 --- a/skgyorugo/commands/emotes.py +++ b/skgyorugo/commands/emotes.py @@ -3,7 +3,7 @@ import tools.smart_privmsg import urllib3 PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 90 GLOBAL_COOLDOWN = 60 @@ -25,7 +25,7 @@ def main(bot: Bot, message: Message): message.channel, "NotLikeThis oopsie woopsie, we've made a fucky wucky. We can't \ get the emotes at the moment. Hopefuwwy UwU wiww wait patientwy \ - tiww we get thiws pwobwem sowted. OwO" + tiww we get thiws pwobwem sowted. OwO", ) return emotes = r1.data.decode("utf-8") diff --git a/skgyorugo/commands/forcehere.py b/skgyorugo/commands/forcehere.py index 9427a12..6e7d263 100644 --- a/skgyorugo/commands/forcehere.py +++ b/skgyorugo/commands/forcehere.py @@ -6,15 +6,6 @@ import sqlite3 import time logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/forcejoin.py b/skgyorugo/commands/forcejoin.py index 062b6fe..950138f 100644 --- a/skgyorugo/commands/forcejoin.py +++ b/skgyorugo/commands/forcejoin.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/forceleave.py b/skgyorugo/commands/forceleave.py index 2ea5fcb..4ae7874 100644 --- a/skgyorugo/commands/forceleave.py +++ b/skgyorugo/commands/forceleave.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/forcenothere.py b/skgyorugo/commands/forcenothere.py index 1b355d1..68edb69 100644 --- a/skgyorugo/commands/forcenothere.py +++ b/skgyorugo/commands/forcenothere.py @@ -6,15 +6,6 @@ import sqlite3 import time logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/here.py b/skgyorugo/commands/here.py index d64f6e3..31ceb1a 100644 --- a/skgyorugo/commands/here.py +++ b/skgyorugo/commands/here.py @@ -6,15 +6,6 @@ import sqlite3 import time logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/join.py b/skgyorugo/commands/join.py index badb0d7..77ff305 100644 --- a/skgyorugo/commands/join.py +++ b/skgyorugo/commands/join.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/latege.py b/skgyorugo/commands/latege.py index 7cfa1ae..7eae204 100644 --- a/skgyorugo/commands/latege.py +++ b/skgyorugo/commands/latege.py @@ -4,19 +4,22 @@ from datetime import datetime import datetime as dt PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 15 GLOBAL_COOLDOWN = 5 STREAM_SCHEDULE = dt.time(17, 30) + def main(bot: Bot, message: Message): start_stream_ts = tools.smart_start_stream_time.start_stream_timestamp() if not start_stream_ts: return start_stream_dt = datetime.utcfromtimestamp(start_stream_ts) - stream_schedule_dt = datetime.combine(datetime.utcfromtimestamp(start_stream_ts), STREAM_SCHEDULE) + stream_schedule_dt = datetime.combine( + datetime.utcfromtimestamp(start_stream_ts), STREAM_SCHEDULE + ) latege_amount = (start_stream_dt - stream_schedule_dt).total_seconds() if latege_amount > 45 * 60: msg = f"{message.channel} is so Latege he might as well have not \ @@ -30,4 +33,3 @@ def main(bot: Bot, message: Message): msg = f"UNBELIEVABLE!!!!! {message.channel} is EARLY by {-latege_amount} seconds!!!!\ This has NEVER happened before POGGERS" bot.send_privmsg(message.channel, msg) - diff --git a/skgyorugo/commands/leave.py b/skgyorugo/commands/leave.py index 6de248c..5cfcd32 100644 --- a/skgyorugo/commands/leave.py +++ b/skgyorugo/commands/leave.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/movedown.py b/skgyorugo/commands/movedown.py index f6deda7..b6d8f71 100644 --- a/skgyorugo/commands/movedown.py +++ b/skgyorugo/commands/movedown.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/moveup.py b/skgyorugo/commands/moveup.py index 8363787..5c062c7 100644 --- a/skgyorugo/commands/moveup.py +++ b/skgyorugo/commands/moveup.py @@ -5,15 +5,6 @@ import ttv_api.users import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/newteams.py b/skgyorugo/commands/newteams.py index 7c44908..cf70770 100644 --- a/skgyorugo/commands/newteams.py +++ b/skgyorugo/commands/newteams.py @@ -6,15 +6,6 @@ import sqlite3 import random logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/nothere.py b/skgyorugo/commands/nothere.py index 9a2fb15..2aca550 100644 --- a/skgyorugo/commands/nothere.py +++ b/skgyorugo/commands/nothere.py @@ -6,15 +6,6 @@ import sqlite3 import time logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/opgg.py b/skgyorugo/commands/opgg.py index d403e8e..420a0d0 100644 --- a/skgyorugo/commands/opgg.py +++ b/skgyorugo/commands/opgg.py @@ -8,15 +8,6 @@ import ttv_api.users from tools import smart_privmsg logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 diff --git a/skgyorugo/commands/queue.py b/skgyorugo/commands/queue.py index 6d8cfd9..a42e916 100644 --- a/skgyorugo/commands/queue.py +++ b/skgyorugo/commands/queue.py @@ -6,15 +6,6 @@ import sqlite3 import tools.smart_privmsg logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/removecommand.py b/skgyorugo/commands/removecommand.py index 4af03a9..671e49a 100644 --- a/skgyorugo/commands/removecommand.py +++ b/skgyorugo/commands/removecommand.py @@ -3,7 +3,7 @@ import sqlite3 import os PERMISSION = 10 -PREFIX = '\\' +PREFIX = "\\" DESCRIPTION = "" USER_COOLDOWN = 0 GLOBAL_COOLDOWN = 0 @@ -13,19 +13,14 @@ PATH = os.path.join(COMMANDS_PATH, "..") def main(bot: Bot, message: Message): - msg = ' '.join(message.value.split(' ')[1:]) - command = msg.split(' ')[0] + msg = " ".join(message.value.split(" ")[1:]) + command = msg.split(" ")[0] command_prefix = command[0] command_name = command[1:] conn = sqlite3.connect(os.path.join(PATH, "database.db")) c = conn.cursor() - c.execute( - "SELECT value FROM command_values WHERE command = ?", - ( - command_name, - ) - ) + c.execute("SELECT value FROM command_values WHERE command = ?", (command_name,)) command_path = os.path.join(COMMANDS_PATH, f"{command_name}.py") hidden_command_path = os.path.join(COMMANDS_PATH, f".{command_name}.py") try: @@ -43,17 +38,11 @@ def main(bot: Bot, message: Message): ( command_name, command_prefix, - ) + ), ) except sqlite3.IntegrityError: - bot.send_privmsg( - message.channel, - f"The command {command_name} doesn't exist." - ) + bot.send_privmsg(message.channel, f"The command {command_name} doesn't exist.") else: - bot.send_privmsg( - message.channel, - f"Successfully removed {command_name}." - ) + bot.send_privmsg(message.channel, f"Successfully removed {command_name}.") conn.commit() conn.close() diff --git a/skgyorugo/commands/scam.py b/skgyorugo/commands/scam.py index b983db4..3b3a0f0 100644 --- a/skgyorugo/commands/scam.py +++ b/skgyorugo/commands/scam.py @@ -1,7 +1,7 @@ from aptbot.bot import Message, Commands, Bot PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 10 GLOBAL_COOLDOWN = 10 diff --git a/skgyorugo/commands/spam.py b/skgyorugo/commands/spam.py index 571a38f..5db59e0 100644 --- a/skgyorugo/commands/spam.py +++ b/skgyorugo/commands/spam.py @@ -2,7 +2,7 @@ from aptbot.bot import Message, Commands, Bot import tools.smart_privmsg PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 30 GLOBAL_COOLDOWN = 15 @@ -18,7 +18,7 @@ def main(bot: Bot, message: Message): if replied_message: msg = replied_message else: - msg = ' '.join(message.value.split(' ')[1:]) + msg = " ".join(message.value.split(" ")[1:]) new_msg = "" while len(new_msg) + len(msg) < MAX_LENGTH: new_msg += msg + " " diff --git a/skgyorugo/commands/t.py b/skgyorugo/commands/t.py index 337f1fa..9c84b7a 100644 --- a/skgyorugo/commands/t.py +++ b/skgyorugo/commands/t.py @@ -3,7 +3,7 @@ import tools.smart_privmsg import scripts.translator PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "Translates a message from any language (supported by google translate) into English. How to use: ?t " USER_COOLDOWN = 15 GLOBAL_COOLDOWN = 5 @@ -15,7 +15,7 @@ def main(bot: Bot, message: Message): msg = replied_message replied_msg_id = message.tags["reply-parent-msg-id"] else: - msg = ' '.join(message.value.split(' ')[1:]) + msg = " ".join(message.value.split(" ")[1:]) replied_msg_id = None trans = scripts.translator.translate(msg) print(trans) diff --git a/skgyorugo/commands/teams.py b/skgyorugo/commands/teams.py index fc90363..b777934 100644 --- a/skgyorugo/commands/teams.py +++ b/skgyorugo/commands/teams.py @@ -6,15 +6,6 @@ import sqlite3 import tools.smart_privmsg logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 PREFIX = "?" diff --git a/skgyorugo/commands/teamsize.py b/skgyorugo/commands/teamsize.py index 02f7535..f50277e 100644 --- a/skgyorugo/commands/teamsize.py +++ b/skgyorugo/commands/teamsize.py @@ -4,15 +4,6 @@ import logging import sqlite3 logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 10 PREFIX = "\\" diff --git a/skgyorugo/commands/uwu.py b/skgyorugo/commands/uwu.py index 0f1e5fe..bf1fdb6 100644 --- a/skgyorugo/commands/uwu.py +++ b/skgyorugo/commands/uwu.py @@ -4,19 +4,10 @@ import logging from tools import smart_privmsg logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler('/var/log/aptbot/logs.log') -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "" USER_COOLDOWN = 0 GLOBAL_COOLDOWN = 0 @@ -27,13 +18,24 @@ PATH = os.path.join(PATH, "..") def main(bot: Bot, message: Message): if message.tags.get("reply-parent-display-name", None): - smart_privmsg.send(bot, message, f"{message.tags['reply-parent-display-name']}, {message.nick} is UwUing you. Will you UwU back? PauseChamp", reply=message.tags['reply-parent-msg-id']) + smart_privmsg.send( + bot, + message, + f"{message.tags['reply-parent-display-name']}, {message.nick} is UwUing you. Will you UwU back? PauseChamp", + reply=message.tags["reply-parent-msg-id"], + ) return try: - user = message.value.split(' ')[1] + user = message.value.split(" ")[1] except IndexError: - smart_privmsg.send(bot, message, f"UwU to you too {message.nick}!", reply=message.tags["id"]) + smart_privmsg.send( + bot, message, f"UwU to you too {message.nick}!", reply=message.tags["id"] + ) return else: - smart_privmsg.send(bot, message, f"{user}, {message.nick} is UwUing you. Will you UwU back? PauseChamp") + smart_privmsg.send( + bot, + message, + f"{user}, {message.nick} is UwUing you. Will you UwU back? PauseChamp", + ) return diff --git a/skgyorugo/commands/youtube.py b/skgyorugo/commands/youtube.py index afe4a6c..b3965d2 100644 --- a/skgyorugo/commands/youtube.py +++ b/skgyorugo/commands/youtube.py @@ -2,7 +2,7 @@ from aptbot.bot import Message, Commands, Bot import yt_api.videos PERMISSION = 99 -PREFIX = '?' +PREFIX = "?" DESCRIPTION = "Get my newest video! Just type ?video" USER_COOLDOWN = 15 GLOBAL_COOLDOWN = 15 @@ -14,7 +14,7 @@ def main(bot: Bot, message: Message): video = yt_api.videos.get_newest_video(CHANNEL_ID) if video: video_link = f"https://www.youtube.com/watch?v={video.video_id}" - msg = f"Watch Peks' latest video \"{video.video_name}\" here: {video_link}" + msg = f'Watch Peks\' latest video "{video.video_name}" here: {video_link}' else: msg = f"Check out my youtube channel here -> https://www.youtube.com/channel/{CHANNEL_ID}" bot.send_privmsg(message.channel, msg) diff --git a/skgyorugo/database_manager.py b/skgyorugo/database_manager.py index 7f079bf..92a8333 100644 --- a/skgyorugo/database_manager.py +++ b/skgyorugo/database_manager.py @@ -5,15 +5,6 @@ import ttv_api.users import logging logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler('/var/log/aptbot/logs.log') -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PATH = os.path.dirname(os.path.realpath(__file__)) logger.debug(f"PATH set to: {PATH}") @@ -25,7 +16,7 @@ logger.debug(f"streamer_login set to: {streamer_login}") def create_variables_db(): - db_name_var = "variables.db" + db_name_var = "variables.db" conn = sqlite3.connect(os.path.join(PATH, db_name_var)) c = conn.cursor() logger.info(f"connected to database {db_name_var}") @@ -71,6 +62,7 @@ def create_variables_db(): conn.commit() conn.close() + def create_lol_database(): db_name_database = "lol_data.db" conn = sqlite3.connect(os.path.join(PATH, db_name_database)) @@ -120,6 +112,7 @@ def create_lol_database(): conn.commit() conn.close() + def create_database(): db_name_database = "database.db" conn = sqlite3.connect(os.path.join(PATH, db_name_database)) @@ -157,16 +150,17 @@ def create_database(): aptbot_id = ttv_api.users.get_users(user_logins=["murphyai"]) broadcaster_id = ttv_api.users.get_users(user_logins=[streamer_login]) if admin_id: - c.execute("INSERT OR IGNORE INTO users VALUES (?, ?)", - (admin_id[0].user_id, 0)) + c.execute("INSERT OR IGNORE INTO users VALUES (?, ?)", (admin_id[0].user_id, 0)) logger.info(f"inserted user {admin_id[0].user_id} with permission {0}") if aptbot_id: - c.execute("INSERT OR IGNORE INTO users VALUES (?, ?)", - (aptbot_id[0].user_id, 0)) + c.execute( + "INSERT OR IGNORE INTO users VALUES (?, ?)", (aptbot_id[0].user_id, 0) + ) logger.info(f"inserted user {aptbot_id[0].user_id} with permission {0}") if broadcaster_id: - c.execute("INSERT OR IGNORE INTO users VALUES (?, ?)", - (broadcaster_id[0].user_id, 1)) + c.execute( + "INSERT OR IGNORE INTO users VALUES (?, ?)", (broadcaster_id[0].user_id, 1) + ) logger.info(f"inserted user {broadcaster_id[0].user_id} with permission {1}") c.execute( @@ -241,7 +235,7 @@ def update_commands_in_database(modules, commands): logger.info(f"connected to database {db_name_database}") for command in commands: - command_name = command.split('.')[0] + command_name = command.split(".")[0] command_permission = modules[command_name].PERMISSION command_prefix = modules[command_name].PREFIX command_description = modules[command_name].DESCRIPTION @@ -258,18 +252,23 @@ def update_commands_in_database(modules, commands): command_user_cooldown, command_global_cooldown, command_last_used, - ) + ), ) logger.info(f"updating commands command_name: {command_name}") logger.debug(f"updating commands command_prefix: {command_prefix}") logger.debug(f"updating commands command_permission: {command_permission}") logger.debug(f"updating commands command_description: {command_description}") - logger.debug(f"updating commands command_user_cooldown: {command_user_cooldown}") - logger.debug(f"updating commands command_global_cooldown: {command_global_cooldown}") + logger.debug( + f"updating commands command_user_cooldown: {command_user_cooldown}" + ) + logger.debug( + f"updating commands command_global_cooldown: {command_global_cooldown}" + ) logger.debug(f"updating commands command_last_used: {command_last_used}") conn.commit() conn.close() + def add_message_to_chat_history(message: Message): if message.command != Commands.PRIVMSG: return @@ -284,7 +283,7 @@ def add_message_to_chat_history(message: Message): rp_display_name = message.tags["reply-parent-display-name"] rp_msg_body = message.tags["reply-parent-msg-body"] rp_msg_id = message.tags["reply-parent-msg-id"] - rp_user_id = int( message.tags["reply-parent-user-id"] ) + rp_user_id = int(message.tags["reply-parent-user-id"]) rp_user_login = message.tags["reply-parent-user-login"] except KeyError: rp_display_name = None @@ -332,22 +331,23 @@ def add_message_to_chat_history(message: Message): message.tags["color"], message.tags["display-name"], int(message.tags["first-msg"]), - int( message.tags["mod"] ), - int( message.tags["room-id"] ), - int( message.tags["user-id"] ), + int(message.tags["mod"]), + int(message.tags["room-id"]), + int(message.tags["user-id"]), message.tags["user-type"], - int( message.tags["turbo"] ), - int( message.tags["subscriber"] ), + int(message.tags["turbo"]), + int(message.tags["subscriber"]), rp_display_name, rp_msg_body, rp_msg_id, rp_user_id, rp_user_login, - ) + ), ) conn.commit() conn.close() + def create_chat_history_database(): conn = sqlite3.connect(os.path.join(PATH, "chat_history.db")) c = conn.cursor() @@ -390,7 +390,7 @@ def update_auto_messages_in_database(modules, auto_messages): c = conn.cursor() for auto_message in auto_messages: - auto_message_name = auto_message.split('.')[0] + auto_message_name = auto_message.split(".")[0] auto_message_cooldown = modules[auto_message_name].COOLDOWN auto_message_end_time = modules[auto_message_name].END_TIME auto_message_last_used = 0 @@ -402,7 +402,7 @@ def update_auto_messages_in_database(modules, auto_messages): auto_message_cooldown, auto_message_end_time, auto_message_last_used, - ) + ), ) except Exception as e: c.execute( @@ -418,7 +418,7 @@ def update_auto_messages_in_database(modules, auto_messages): auto_message_cooldown, auto_message_end_time, auto_message_name, - ) + ), ) conn.commit() conn.close() diff --git a/skgyorugo/lol_api/match_v5.py b/skgyorugo/lol_api/match_v5.py index 5341c9f..197bf0b 100644 --- a/skgyorugo/lol_api/match_v5.py +++ b/skgyorugo/lol_api/match_v5.py @@ -1,14 +1,3 @@ from lol_api import * logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler('/var/log/aptbot/logs.log') -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) - - diff --git a/skgyorugo/lol_api/spectator_v4.py b/skgyorugo/lol_api/spectator_v4.py index 3c2a692..c678236 100644 --- a/skgyorugo/lol_api/spectator_v4.py +++ b/skgyorugo/lol_api/spectator_v4.py @@ -2,15 +2,6 @@ from lol_api import * from typing import Optional logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) @dataclass diff --git a/skgyorugo/lol_api/summoner_v4.py b/skgyorugo/lol_api/summoner_v4.py index fbb4840..c234b9e 100644 --- a/skgyorugo/lol_api/summoner_v4.py +++ b/skgyorugo/lol_api/summoner_v4.py @@ -1,15 +1,6 @@ from lol_api import * logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler('/var/log/aptbot/logs.log') -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) @dataclass @@ -22,6 +13,7 @@ class Summoner: revision_date: int summoner_level: int + def get_summoner_from_puuid(puuid: str) -> Optional[Summoner]: endpoint = f"/lol/summoner/v4/summoners/by-puuid/{puuid}" url = BASE_URL + endpoint @@ -33,7 +25,9 @@ def get_summoner_from_puuid(puuid: str) -> Optional[Summoner]: headers=HEADER, ) if r.status != 200: - logger.warning(f"Couldn't retrieve summoner with puuid: {puuid}. Status code {r.status}") + logger.warning( + f"Couldn't retrieve summoner with puuid: {puuid}. Status code {r.status}" + ) return None data = json.loads(r.data.decode("utf-8")) return Summoner( @@ -43,7 +37,7 @@ def get_summoner_from_puuid(puuid: str) -> Optional[Summoner]: data["name"], data["profileIconId"], data["revisionDate"], - data["summonerLevel"] + data["summonerLevel"], ) @@ -68,6 +62,5 @@ def get_summoner_from_name(name: str) -> Optional[Summoner]: data["name"], data["profileIconId"], data["revisionDate"], - data["summonerLevel"] + data["summonerLevel"], ) - diff --git a/skgyorugo/main.py b/skgyorugo/main.py index 68d8bb5..1c2dd35 100644 --- a/skgyorugo/main.py +++ b/skgyorugo/main.py @@ -29,15 +29,6 @@ reload(database_manager) reload(analyze_auto_message) logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) PATH = os.path.dirname(os.path.realpath(__file__)) logger.info(f"PATH set to: {PATH}") @@ -120,7 +111,9 @@ def start(bot: Bot, message: Message): i += wait started = tools.smart_start_stream_time.update_start_stream_timestamp() if started == "START": - bot.send_privmsg(message.channel, "Stream has started, you can now use ?join") + bot.send_privmsg( + message.channel, "Stream has started, you can now use ?join" + ) elif started == "END": bot.send_privmsg(message.channel, "Stream has ended") if i >= 30: diff --git a/skgyorugo/requirements.txt b/skgyorugo/requirements.txt index 0c43470..bbabe65 100644 --- a/skgyorugo/requirements.txt +++ b/skgyorugo/requirements.txt @@ -1,34 +1,45 @@ -beautifulsoup4==4.10.0 +beautifulsoup4==4.11.1 +black==22.3.0 blis==0.7.7 catalogue==2.0.7 -certifi==2021.10.8 +certifi==2022.5.18.1 charset-normalizer==2.0.12 -click==8.0.4 +click==8.1.3 cymem==2.0.6 -deep-translator==1.8.1 -en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0-py3-none-any.whl +deep-translator==1.8.3 +en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.3.0/en_core_web_sm-3.3.0-py3-none-any.whl +flake8==4.0.1 +flake8-black==0.3.3 idna==3.3 -Jinja2==3.1.1 +Jinja2==3.1.2 langcodes==3.3.0 MarkupSafe==2.1.1 -murmurhash==1.0.6 -numpy==1.22.3 +mccabe==0.6.1 +murmurhash==1.0.7 +mypy-extensions==0.4.3 +numpy==1.22.4 packaging==21.3 +pathspec==0.9.0 pathy==0.6.1 +platformdirs==2.5.2 preshed==3.0.6 +pycodestyle==2.8.0 pydantic==1.8.2 -pyparsing==3.0.7 +pyflakes==2.4.0 +pyparsing==3.0.9 python-dotenv==0.20.0 requests==2.27.1 smart-open==5.2.1 -soupsieve==2.3.1 -spacy==3.2.4 +soupsieve==2.3.2.post1 +spacy==3.3.0 spacy-legacy==3.0.9 spacy-loggers==1.0.2 -srsly==2.4.2 -thinc==8.0.15 -tqdm==4.63.1 -typer==0.4.0 -typing-extensions==4.1.1 +srsly==2.4.3 +thinc==8.0.16 +tomli==2.0.1 +tqdm==4.64.0 +typer==0.4.1 +typing-extensions==4.2.0 urllib3==1.26.9 wasabi==0.9.1 +websocket-client==1.3.2 diff --git a/skgyorugo/scripts/alwase.py b/skgyorugo/scripts/alwase.py index b538bdb..b44597c 100644 --- a/skgyorugo/scripts/alwase.py +++ b/skgyorugo/scripts/alwase.py @@ -2,6 +2,7 @@ from aptbot.bot import Bot, Message, Commands import tools.smart_privmsg import random + def alwase(bot: Bot, message: Message): if "always" not in message.value.lower(): return @@ -9,6 +10,10 @@ def alwase(bot: Bot, message: Message): replied_msg_id = message.tags["id"] except KeyError: replied_msg_id = None - msgs = ["It's alwase Madge", "Why don't you spell it alwase? Madge", "Spell it alwase or peepoArriveBan"] + msgs = [ + "It's alwase Madge", + "Why don't you spell it alwase? Madge", + "Spell it alwase or peepoArriveBan", + ] msg = random.choice(msgs) tools.smart_privmsg.send(bot, message, msg, reply=replied_msg_id) diff --git a/skgyorugo/scripts/chatting.py b/skgyorugo/scripts/chatting.py index 5d79de3..104094e 100644 --- a/skgyorugo/scripts/chatting.py +++ b/skgyorugo/scripts/chatting.py @@ -10,10 +10,10 @@ def chatting(bot: Bot, message: Message): return msg = "" if "reply-parent-msg-body" in message.tags: - if message.value.split(' ')[1] == "Chatting": - msg = ' '.join(message.value.split(' ')[1:]) + if message.value.split(" ")[1] == "Chatting": + msg = " ".join(message.value.split(" ")[1:]) else: - if message.value.split(' ')[0] == "Chatting": + if message.value.split(" ")[0] == "Chatting": msg = message.value if msg: tools.smart_privmsg.send(bot, message, msg) diff --git a/skgyorugo/scripts/clean_queue.py b/skgyorugo/scripts/clean_queue.py index 9bf9d43..635b2b9 100644 --- a/skgyorugo/scripts/clean_queue.py +++ b/skgyorugo/scripts/clean_queue.py @@ -11,15 +11,6 @@ STREAMER_PATH = os.path.abspath(os.path.join(__file__, "../..")) streamer_login = os.path.split(STREAMER_PATH)[1] logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) def clean_queue(): diff --git a/skgyorugo/scripts/unit_converter.py b/skgyorugo/scripts/unit_converter.py index 32382cd..f9fb532 100644 --- a/skgyorugo/scripts/unit_converter.py +++ b/skgyorugo/scripts/unit_converter.py @@ -35,12 +35,12 @@ def _tometric(text: str) -> tuple[list[tuple[int, int]], list[float]]: found_single = False for w in doc: # print(w.text, w.pos_) - if w.pos_ in {'AUX', 'VERB', 'ADP'}: + if w.pos_ in {"AUX", "VERB", "ADP"}: if feet_was_last and not next_should_be_double: ft_inch.append((feet, 0.0)) feet = 0 inches = 0 - if w.like_num or w.pos_ == 'NUM': + if w.like_num or w.pos_ == "NUM": # index_of_previous_token = w.i - 1 # try: # prev_token = doc[index_of_previous_token] @@ -70,11 +70,11 @@ def _tometric(text: str) -> tuple[list[tuple[int, int]], list[float]]: ft_inch.append((feet, 0.0)) feet = float(w.text) feet_was_last = True - elif next_token.lemma_ in {"inch", "\""}: - if next_token.lemma_ == "\"" and next_should_be_double: + elif next_token.lemma_ in {"inch", '"'}: + if next_token.lemma_ == '"' and next_should_be_double: inches = float(w.text) next_should_be_double = False - elif next_token.lemma_ == "\"": + elif next_token.lemma_ == '"': inches = 0 elif next_should_be_double: feet = 0 diff --git a/skgyorugo/tools/smart_start_stream_time.py b/skgyorugo/tools/smart_start_stream_time.py index 6ffa8ff..dc8a729 100644 --- a/skgyorugo/tools/smart_start_stream_time.py +++ b/skgyorugo/tools/smart_start_stream_time.py @@ -9,15 +9,6 @@ from scripts import clean_queue from typing import Optional logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) STREAMER_PATH = os.path.abspath(os.path.join(__file__, "../..")) logger.debug(f"STREAMER_PATH set to: {STREAMER_PATH}") @@ -100,7 +91,7 @@ def update_start_stream_timestamp() -> Optional[str]: if time.time() < last_checked + CHECK_STREAMTIME_CD: logger.info(f"returned cached start stream time: {start_stream_ts}") conn.close() - return + return stream_info = ttv_api.stream.get_streams(user_logins=[streamer_login]) logger.info(f"used twitch api to get stream info") @@ -172,4 +163,4 @@ def update_start_stream_timestamp() -> Optional[str]: ) conn.close() logger.info(f"returned cached start stream time: {start_stream_ts}") - return + return diff --git a/skgyorugo/variable_manager/parser.py b/skgyorugo/variable_manager/parser.py index 9bf3044..52c3b53 100644 --- a/skgyorugo/variable_manager/parser.py +++ b/skgyorugo/variable_manager/parser.py @@ -31,11 +31,7 @@ class Expression: AND list_values.id = ? AND methods.name = ? """, - ( - self.name, - self.list_id, - self.method - ) + (self.name, self.list_id, self.method), ) conn.close() pass diff --git a/skgyorugo/yt_api/videos.py b/skgyorugo/yt_api/videos.py index 9c68f72..d0e9fc2 100644 --- a/skgyorugo/yt_api/videos.py +++ b/skgyorugo/yt_api/videos.py @@ -10,8 +10,12 @@ class Video: def get_newest_video(channel_id: str) -> Optional[Video]: get_video_snippets = "?part=snippet" - get_url = URL + get_video_snippets + \ - f"&channelId={channel_id}&order=date&type=video" + f"&key={API}" + get_url = ( + URL + + get_video_snippets + + f"&channelId={channel_id}&order=date&type=video" + + f"&key={API}" + ) http = urllib3.PoolManager() r = http.request( -- 2.30.2